Look the code below. I’d like to replace USERNAME by the field name received in the parameter field. This method must be able to make some search on several fields.
Thank,
public void Searching(string field, string stringToSearch)
{
var res =
from user in _dataContext.USERs where
user.USERNAME.Contains(stringToSearch)
select new
{
Id = user.ID,
Username = user.USERNAME
};
}
You need to forget about the anonymous type, maybe use
Tuple<int,string>instead; but: how about: