c# - Searching item in List -


  man [] PRN = new Person [] {new Person {Name = "Robert", RList = {new ReceipeList {NameofRecipie = "Coak"}, new ReceipeList {NameofRecipie = "pizza"}}}, new person {name = "Rahim", RList = {new ReceipeList {NameofRecipie = "Coak"}, new ReceipeList {NameofRecipie = "OnionBread "}}},};  

When an item search

  ReceipeList lstr = new ReceipeList (); Lstr.NameofRecipie = "Coak";  

Using

  lst select var query = from lst in PRN where (lst.RList.Contains (lstr));  

This does not return any results.

  foreach (query v v) {ordered: (v.Name.ToString (+) + ';); foreach (ReceipeList lst in v.RList) {Console. Write (lst.NameofRecipie.ToString () + ",");} console. Wrightite ();}  

This is not working because you search for a specific example (by reference). For this reason, your query will return only those values ​​which will have an example of your typical continent institution, and not An empty list that you are specifying, the same With Uly.

You can achieve this task ReceiptList, or double again to your query:

  string lstr = "coak"; Var query = in Piaran where lst.RList.Any (r = & gt; r.NameofRecipie == lstr) Select lst;  

this works because instead of looking for a specific example, ReceipeList uses the method () to find instances by a prediction.


Comments

Popular posts from this blog

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -