linq - Selecting distinct objects from collection of objects using lambda expressions -
We have a project using Fluent NHibernate, an object called BluePart, with the property of Om of Type Om.
Public category BluePart: DomainEntity {... Public Virtual Om Om {get; Set; The OM object, including OemCode and OemDescription, has many properties. Public class ohm: DomainEntity {... public virtual string OemCode {get; Set; } Public virtual string OemDescription {get; Set; }}
I am trying to create a Linux query through Lambda Express, which will get all the different ohm from a list of Blue Purses (2.7 million records). Ideally this class should be created (which runs in & lt; 1sec):
select specific o.OmCode, o. Internal oh oo oiiIid = b.om_id from OpenEditionation BluePart B-
The query I created below gives om, regardless of specificity.
var oem = repository.Query & lt; BluePart & gt; (). X = & gt; New Om {OemCode = x.Oem.OemCode, OemDescription = x.Oem.OemDescription}). ToList ();
I thought it would be easy to build this question, but this is not happening. When running GroupBy (.GroupBy (z => z.OemCode)), I keep an error by saying that property I am trying to do is not property of Group B (it should not be because I have a property I am grouping about: About Om:
How about:
var oem = repository query & lt; BluePart & gt; (). (X => New {OemCode = x.Oem.OemCode, OemDescription = x.Oem.OemDescription}.) Undoubtedly () .Olist ();
this only will give you special Code / description will be added, but it seems that you are interested in all.
Alternatively, using grouping:
var oem = repository. Query & lt; BluePart & gt; () .GroupBy (x = & new; {OemCode = x.Oem.OemCode, OemDescription = x.Oem.OemDescription}). To create a list ();
< / Pre>This will group you all the
BluePart
organizations by the OEM code / description.
Comments
Post a Comment