c# - Fluent NHibernate: How to tell it not to map a base class -
I have been googling and stackoverflowing for the past two hours and my question could not be answered:
< P> I am using ASP.NET MVC and NHibernate, and whatever I am trying to do is to manually map my institutions without mapping my base class. I am using the following conference: Public class car: EntityBase {public virtual user user {get; Set; } Public virtual string plate number {get; Set; } Public Virtual String {get; Set; } Public virtual string model {get; Set; } Public Virtual Int Year {Received; Set; } Public virtual string color {get; Set; } Public Virtual String Insurers {get; Set; } Public Virtual String Policyholder {Received; Set; }}
Where EntityBase should not be mapped.
My NHibernate assistant class looks like this:
Nom place model. Public class NHibernateHelper {Private String String Connection String; Private static ISessionFactory session; Private static Fluent Configuration Config; /// & lt; Summary & gt; /// becomes a session for NHibernate /// & lt; / Summary & gt; /// & lt; Value & gt; Session factory & Lt; / Value & gt; Private stable ISessionFactory SessionFactory {get {if (sessionFactory == empty) {// Get connection string connection String = ConfigurationManager.ConnectionStrings ["connectionString"]. ConnectionString; // Create Configuration Configuration Structure = Flu. Configure () Database (PostGrace SQL Configuration. PostgreSQL 82. Connection String); // Add Mapping Config. Mappings (adampling); // session creation session session = config.BuildSessionFactory (); } Return session; }} /// & lt; Summary & gt; Add /// Mapping /// & lt; / Summary & gt; /// & lt; Param name = "mapConfig" & gt; Map Config & Lt; / Param & gt; Private static Zero AddMappings (Mapping Configuration Map Config) {// Load Assembly where institutions are assembly assembly = assembly live. Load ("myProject"); MapConfig.FluentMappings.AddFromAssembly (assembly); Ignore basic types. Automap = automap Assembly (assembly). IgnoreBase & lt; EntityBase & gt; (). IgnoreBase & lt; EntityBaseValidation & gt; (); MapConfig.AutoMappings.Add (Automap); // Configure Mapping Map Merge Mergemings (); } /// & lt; Summary & gt; /// Opens the session to create a DB connection using the SASIFFECTURE. /// & lt; / Summary & gt; /// & lt; Returns & gt; & Lt; / Returns & gt; Public Stable ESSN Openness () {session session Open Session (); } /// & lt; Summary & gt; /// closes the NHibernate session /// & lt; / Summary & gt; Public Static Zero CloseSession () {SessionFactory.Close (); }}
The error I am receiving is:
The system. Collection: Expression: There are 2 general parameters in type or method, but 1 common argument (s) were provided, a common argument should be provided for each common parameter
this would be Is when i want to add mapping Is there any other way to manually map your organizations and not NHibernate to map the base class?
If you do not want to automate a category, then I IAutoMappingOverride & lt; T & gt;
I am not about your database, but it may look like this:
public class caroverride: IAutoMappingOverride & lt; Cars & gt; {Public Zero Override (Automapping & lt; Car & gt; Mapping) {Mapping.ID (x => x.id, "car id"). Inappropriate price (0). Generated Recognise (); Mapping Reference (x => x.User, "UserId"). Non (); Mapping Map (x = & gt; x.PlateNumber, "plate number"); // Other properties}}
Assume that these maps are centrally located, you can load them on your own automation:
var automap = AutoMap.Assembly (assembly). Unknown & lt; EntityBase & gt; (). IgnoreBase & lt; EntityBaseValidation & gt; () .UseOverridesFromAssemblyOf & lt; CarOverride & gt; ();
Comments
Post a Comment