c# - Comparing an entity with array using LINQ -
I have the string array named code I want to compare with
batch unit and receive all records that match the unit's bracket field. I am using the
Unit Framework 6 .
class batch {int batchId {get; Set;} string string {get} Set;} string info {get; Set;} date time date {receive; Right now I am using it in the foreach foreach (in bat items) in batches {{code} var res = Opt.Batch.Where (i => i.batchname == item) .FirstOrDefault (); Batchlist.Add (race); }
How do I do with LINQ without foreach
You can change the entire forechee loop and keep the line of code by changing i.batchname == item with the following:
batches.Contains (i.batchname) Then you can add all the items in your list together because it will return all batches where The name contains the batch array.
The variable RES will return a countable that can then be either blocked around to add to your list or you can use a list which allows AddRange ().
Hope it helps.
Comments
Post a Comment