> After that I created the following class under Nop.BusinessLogic in the folder named MOD MOD_License.cs using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data.Objects; using NopSolutions.NopCommerce.BusinessLogic.MOD; using NopSolutions.NopCommerce.BusinessLogic.Data;
publicstatic MOD_License GetMOD_LicenseByEmail(string sEmail) { var db = ObjectContextHelper.CurrentObjectContext; return db.MOD_Licenses.SingleOrDefault(x => x.Email.ToLower() == sEmail.ToLower()); }
publicstatic IList<MOD_License> GetAllLicenses() { var db = ObjectContextHelper.CurrentObjectContext; return db.MOD_Licenses.OrderBy(x => x.Email).ToList(); }
publicstaticvoid Save(MOD_License license) { var db = ObjectContextHelper.CurrentObjectContext;
if (license.LicenseID == 0) { // new record db.MOD_Licenses.AddObject(license); } else { // existing record if (!db.IsAttached(license)) db.MOD_Licenses.Attach(license); }
db.SaveChanges(); } } }
> Finally I created , build and run Licenses.aspx page:
In case it helps, in 1.90 you no longer need to manually add the ObjectSet for your new entity to the object context. This is generated using tt templates as soon as you save the edmx.
However, if you are adding a new entity in a NEW namespace, you will need to update the tt template used for generating the object context to include your namespace (just add a using statement at the top).
The other big change is that we 1.90 uses dependency injection. If you look at how some of the other services are constructed you should figure it out.
I think you need to register your service AlbumService in case you haven't done it. In NopSolutions.NopCommerce.BusinessLogic.Infrastructure.UnityDependencyResolver there is a method ConfigureContainer that registers all interfaces with their types in the UnityConatainer, so that you can resolve them with Resolve<IAlbumService>. Just add this code in this method: container.RegisterType<IAlbumService, AlbumService>(new UnityPerExecutionContextLifetimeManager());
True 7Spikes, that's how i figured out the same problem. But i find this is a dirty way.
We can see in UnityDependencyResolver.cs the following comment :
//Take into account that Types and Mappings registration could be also done using the UNITY XML configuration //But we prefer doing it here (C# code) because we'll catch errors at compiling time instead execution time, if any type has been written wrong.
Somebody has an idea about the UNITY XML configuration and how to implement this ?
As well as registering in the UnityDependencyResolver I had also to add to the BaseNopMasterPage.cs and the BaseNopUserControl.cs. Is there an easier way? (And I am still getting problems at run time which I need to resolve.)