DNN deprecated methods on upgrade - upgrade

I'm trying to upgrade my old DNN website to DNN version 9.8.0. The problem is that I have one custom module installed and it is using deprecated methods that I'm resolving using the table of deprecated methods and I ran on one issue that I don't really understand what to do with it:
retRole = DotNetNuke.Security.Roles.RoleProvider.Instance().GetRole(module.PortalId, roleid);
Error is: 'DotNetNuke.Security.Roles.RoleProvider' does not contain a definition for 'GetRole' and no extension method 'GetRole' accepting a first argument of type 'DotNetNuke.Security.Roles.RoleProvider' could be found (are you missing a using directive or an assembly reference?)
In the table of deprecated method, for public virtual RoleInfo GetRole(int portalId, int roleId) it says: Deprecated in DotNetNuke 6.2. Roles are cached in the business layer
Does anyone knows what it means and how to resolve this?

Instead of using the RoleProvider, I would use the RoleController:
retRole = DotNetNuke.Security.Roles.RoleController.Instance().GetRoleById(module.PortalId, roleid);
In DNN9.8, RoleProvider doesn't have the method GetRole anymore.

Related

Autofac Interface Ambiguity

"The ambiguity, is in the box" - Monty Python.
Autofac is having a problem resolving an interface. See attached solution.
The Interface, IAmbiguous, is defined in project ACommon. It is implemented in project AInjectable. The AInjectable project does not / cannot reference ACommon. The AInjectable project defines IAmbiguous as an existing item brought in with a file link.
The UI project calls ACommon Inject and attempts to register the AInjectable assembly. IAmbiguous is not ambiguous initially but after a builder.RegisterAssemblyTypes command it becomes "ambiguous in the namespace." There is no error thrown when the container is built but the registration is not there.
Registration can be done "AsImplementedInterfaces" if Named and Keyed is not used. But then there is no way to Resolve the registration because the service IAmbiguous is "ambiguous in the namespace."
This question was double-posted as an issue on Autofac. It is not an Autofac problem. I will copy/paste the answer from the issue in here; for future readers, if you want to see the repro solution, go check out the full issue
What you're doing by including the same interface in two different assemblies isn't something you should be doing. Note that by doing that, your AInjectable class is not implementing the interface from the ACommon project. It's implementing a different but identically named interface.
This sort of thing is a problem - having the same type (interface, class, whatever) name in two different assemblies. We even had a problem (#782) where we had a System.SerializableAttribute in Autofac as a shim for .NET Core. You really just can't do that.
You'll also see the same thing if you try to make a static extension method class that has the same namespace and name as some other static extension method class. Ambiguous references.
Without doing Reflection.Emit style code generation, you won't be able to declare an interface in one assembly ("Assembly A") and implement that interface in a different assembly ("Assembly B") without having Assembly B reference Assembly A. That's just how .NET works. What you're seeing is a manifestation of that when you use Autofac, but it's not caused by Autofac. It's caused by you doing something you shouldn't be doing in .NET.
The fix is to define your interfaces in a separate assembly that everyone implementing the interfaces can reference. (Or you can try to dynamically generate code using Reflection.Emit or Roslyn or something, but that's waaaay harder.)

Entity Framework 7 Errors from Key, Collection, Reference definitions missing in ASP.NET Beta 8

Problem
I am having trouble with upgrading my beta7 application to beta8. I had problems with over 50 errors, but now have gotten it down just to EF7. It was recommended by stack overflow friends and users that I ask this question specifically.
Entity Framework Error
Error CS1061 'EntityTypeBuilder<Unit>' does not contain a definition for 'Collection' and no extension method 'Collection' accepting a first argument of type 'EntityTypeBuilder<Unit>' could be found (are you missing a using directive or an assembly reference?) SampleProject.DNX 4.5.1
I get the same error for Reference as well.
I have the following code in my OnModelCreating(ModelBuilder builder) method in my DbContext.cs file.
builder.Entity<Unit>(entity =>
{
entity.HasKey(unit => unit.UnitId);
entity.Collection(unit => unit.UnitBins).InverseReference(bin => bin.BinUnit)
.ForeignKey(bin => bin.UnitId).Required(true);
entity.Reference(u => u.RefUnitType).InverseReference().ForeignKey<Unit> (u => u.RefUnitTypeId).Required();
});
The problem is that EntityBuilder does not seem to have definitions for Collection and Reference. This is about the second or third time this kind of logic has been refactored in EF it feels like and so I am very confused as to how to rewrite my logic above.
Attempts:
I tried the following things:
I tried using intellisense in VS15, but nothing similar was found
I have searched the EF7 issues GitHub page, but didn't see anything
I also tried dnu restore just to be sure the upgrade didn't do something strange with my project.json lock.
Using entity.HasKey() instead of entity.Key(), but have not found other methods comparable to the others?
Now that beta8 is feature complete, I may rewrite significant portions of my project. However, for now I need to resolve these errors so that I can compile the project again. Any help, assistance, and advice rendered would be greatly appreciated.
Collection => HasMany
Reference => HasOne
InverseReference => WithOne

Error using DbContextBaseClass in EntityFramework Reverse POCO Code First Generator

Error when using a DbContextBaseClass that does not implement a constructor,is there any documentation,Example or Demo on how to use DbContextBaseClass in the template setting to make ASP.NET Identity works ?
i used the guide in the comment:
DbContextBaseClass = "DbContext"; // Specify what the base class is for your DbContext. For ASP.NET Identity use "IdentityDbContext<ApplicationUser>"
but i always end up with two a compile errors :
1- The type or namespace name 'IdentityDbContext' could not be found
(are you missing a using directive or an assembly reference?)
2- The type or namespace name 'ApplicationUser' could not be found
(are you missing a using directive or an assembly reference?)
Apparently someone else is having the same issue :
Link Here
As the ASP.NET identity already includes all the entity framework code within your project, there is no need to reverse engineer it.
I would instead use the Reverse POCO generator to reverse engineer all your own tables, and add a filter to exclude the ASP.NET identity tables alone.
TableFilterExclude = new Regex("^__MigrationHistory$|^AspNetRoles$|^AspNetUserClaims$|^AspNetUserLogins$|^AspNetUserRoles$|^AspNetUsers$");

Entity framework Beta 3 database, does not give DeleteOnSubmit

I do not get context DeleteOnSubmit!! All other functions like Add, Count, etc… work fine! Due to this, I cannot delete the record.
Error 1 'System.Data.Entity.DbSet<mvc2db.Company_Dext>' does not contain a
definition for 'DeleteOnSubmit' and no extension method 'DeleteOnSubmit' accepting
a first argument of type 'System.Data.Entity.DbSet<mvc2db.Company_Dext>' could be
found (are you missing a using directive or an assembly reference?)
I am using Visual Studio 2012 Premium edition
thanks
In Entity Framework 5, there is no DeleteOnsubmit instead there is .Remove(record entity).

What happened to the Rx Switch() operator?

I am working my way through the Hands-On-Labs for reactive extensions (Rx HOL .NET.pdf) which I downloaded from the data developer center (here) a few days ago.
I added these references to my project, using NuGet:
System.Reactive 1.0.10621.0
System.Reactive.Windows.Forms 1.0.10621.0
I'm almost done with the labs, but I've hit a snag trying to implement the .Switch() example, Visual Studio can't locate the extension method:
'System.IObservable'
does not contain a definition for
'Switch' and no extension method
'Switch' accepting a first argument of
type
'System.IObservable'
could be found (are you missing a
using directive or an assembly
reference?)
Now I know this Hands On Labs document is out of date, because certain things have been renamed (FromEvent became FromEventPattern) and certain things were removed (RemoveTimeStamp) and this document does not reflect that. For the life of me I cannot guess what they renamed Switch to be, or figure out what assembly they might have moved it to, or find a comprehensive list of release notes that indicate it was removed.
Anyone know where I can find Switch and what it's current name is?
The Switch extension method doesn't extend IObservable<T> - it extends IObservable<IObservable<T>>. The full signature is:
IObservable<TSource> Switch<TSource>(this IObservable<IObservable<TSource>> sources)
Try typing Observable.Empty<IObservable<object>>(). and see if Switch appears then.
If not, check your using namespace declarations.