c# - Querying the id of an entity using linq -


in following method trying fetch username passing id value ids passed parameter can multiple values in csv's (eg: 1,2) , returned calling function ienumerable.

code follows below :

[nonaction] public static ienumerable<userprofile> searchcmsadmins(string s) {     //var searchresults = entities.userprofiles.where(item =>item.username.contains(s));     //return searchresults;      string[] ids = s.split(',');      ienumerable<userprofile> results = null;     ilist<userprofile> user = new list<userprofile>();      (int = 0; < ids.length; i++)     {         int id = convert.toint32(ids[i].tostring());         var entity = entities.userprofiles.where(item => item.userid);         //user.add(entity);         results = results.concat(entity);     }      return results; } 

any appreciated.

try using contains:

var results = entities.userprofiles.where(item => ids.contains(item.userid)); 

http://msdn.microsoft.com/en-us/library/ms132407.aspx


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -