NHibernate intermediate table mapping by code -


I know that there are similar questions on stack overflow on this subject, but none of them can solve my problem. With this I have been trapped for at least two days, so here is my question:

I have two tables, one of which is the many-to-many relationship, such as :

  department * - * person  

I do not want to use a many-to-many relationship, but two multiple-to-one and Defined

My Institutions

  Public Class Division {Public Virtual Ent ID (get; Set;} Public Virtual Assistant & lt; L & gt; ; Lms {get; set;}} public class person {public virtual id id (get; set;} public virtual eilist & lt; lam & gt; lms {get; set;}} public square lam {public virtual department Department {Received; Set;} Public Virtual Person Public Settings Department Mapping: Class Mapping & lt;    

Department & gt; {Public department mapping () {id (x => x.Id, map = & gt; map. Generator.); Bag (x = & gt; x.Lams, col = & gt; {col.Key (k = & gt; k.Column ("DepartmentId"); col.Inverse (true);}, r = & gt; R.OneToMany ()); }} Public Sector Person Mapping: Class Mapping & lt; Person & gt; {Public person mapping () {id (x => x.id, map = & gt; map. Generator.); Bag (x => x.Lams, col = & gt; {col.key (k = & gt; k.column ("PersonId"); col.Inverse (true);}, r = & gt; R.OneToMany ()); }}

Match Mapping:

  Public Class LamMapping: Classmapping Late & gt; {Public Lam Mapping () {Various (X => X. Department, Map = & gt; {map.Column ("DepartmentId");}); ManyToOne (x = & gt; x.Person, map = & gt; {map.Column ("PersonId");}); }}  

If I try to run my application, I get the following error message:

Wrong syntax near the 'index'. If this table is done as a part of the signal, then the keywords and brackets together are now necessary. See SQL Server Books Online for the proper syntax.

Will someone please tell me, what's wrong with my code?

mapping is is correct (at least for me It was working) So, the question is where does your exception come from?

But if - a portion of your mapping is not shown - Assuming that some of the property exists, assume that index is like this:

  // Entity public class person ... // C # property named index publication A virtual int index {get} set;} ... // mapping public class person mapping: class mapping & lt; person & gt; {public person mapping () {... // that by default the column index property will be (X = & gt; x.index)  

It is selected like SELECT

  SELECT id, index from person  

and SQL Server in the world, which will cause the error:

Message 1018, Level 15, State 1, Line 1 'Index' has the wrong syntax if this table And has been a part of, you need keywords and brackets with a.

Therefore, because the mapping shown above is correct, I suspect some part like this

If this is the case, then we

< Pre> ... property (x => x.index, x = & gt; {x.Column ("[index]");});

Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -