entity framework - Linq to Entities Select clause with lambda -


I am working on a new project and we are using unit framework and god leads when lambda Would like to use questions. One thing is that we want to take a hard time to choose how to choose two columns in addition to how to choose differently, we have a table in which there are many entries for a vendor but we only list the vendors and a dictionary Want to load in the object. This fails because it is trying to add a significant value in writing that has already been added. Take the following query Dictionary & lt; Int, string & gt; Dict = new dictionary & lt; Int, string & gt; (); Dict = GetWamVendorInfo (). AsEnumerable (). Where (x => x.vendor_name! = Null & x.vendor_id! = Null) //. Selection (x = & gt; x.vendor_id). (Undoubtedly). (2). Todoquin (o => gt; purse (o.vender_id.ToString ()), o = & gt; o.vander_name);

What I would like to do, only select vendor_id and vendor so that we can only get specific records.

Any help would be greatly appreciated.

Thanks,

Rhonda

An anonymous type Experiment:

  // The first bit of query. Select (x = & gt; new {seller = x.vendor_id, VendorName = xVendor_name}). Undoubtedly () .Oxisation (O => O. VanderID, O => O. Vandernam);   

I removed the call on take (2) , because it was not clear why you want it - and the seller ID , Which I was already expecting to be an integer type.

Note that you should remove approximately definitely asenumerable calls from your query - currently you all Vendors will bring and filter with the object from LINQ. There is no point in making any blank dictionary and then ignoring it completely. I should have your full query:

  var vendors = GetWamVendorInfo (). Select (x = & gt; new {seller ID = x.vendor_id, VendorName = x.vendor_name}). Undoubtedly (). Oignity (o => O. vendor ID, o => O. vender name);   

On the one hand, you should ask your god why wants to use Lambda expression everywhere (in opposition to possibly query expressions), different syntax options Using different conditions ends with a more readable code - it is advisable to be flexible on this front.

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -