c# - NHibernate Linq : Contains Statement -


As an example, suppose you have such a class

  ** Person * * Ent Individual ID String Person Name Business Location Location ** Business Location ** String City String State List & lt; Int & gt; Zipcode  

(There are many places in the zipcode that can be present in locations)
(Ignore also that instead of zipcode ints String should be, this is just an example)

To say that business locations are present in many zodiacs.

Now I am trying to pull all the people back into the table, for example, I want all those who have a zipcode of 32567.

(Looking at the list of IDs, it works, I am trying to do this, unlike, an ID has been given, I want a list of people)

  Public People GetPersonsByBusinessZipCode (Int zipcode) {List & lt; Person & gt; PersonList = this.GetAllQueryable (). Where (x = & gt; x.Locations.ZipCodes.Contains (zipcode)). ToList (); }  

It has been mapped as in Fluent.

  Hashni & lt; Int & gt; (X = & gt; x.ZipCodes). Table ("BusinessLocationsZipCodes") .kolom.ad ("Business Location ID"). Inverted (). Element ("zipcode") .AsBag () .Cascade.None (). Cache.ReadOnly ();  

BusinessLocationZipCodes is just a reference table, which can have several zip codes in a business location, so HasMany is there.

I know that the reverse works, if I have given a list, zipcode and I am trying to find the business locations contained in the list of zodiac works (unless mapping is not a zipcode and There is no list of zip codes).

If anyone has an answer, I would appreciate it.

Apparently I got spoiled because I have two accounts that I did not know, so It is my OpenID, in any way I am not sure about NullReferenceException, it is working with any of the following sections in NHibernate namespaces with any link which I work below. But I only get NullReferenceException when I try to join it. As I mentioned above, if I just bring back the list of zipcode, I do not get the tap reference exception. So my mapping works, but in this I can not return the list of business based on the statement.


Comments