I Have one table.
There is one column name is branch. Which contains comma separated values. Like this
1,2
2,4
5,6
3,4
6,8
4,9,7
And so on…
And I have one List<string> which contains two values 3 and 4.
I need a database query which will fetch all columns data either contains 3 or 4.
So out put will be
2,4
3,4
4,9,7
And I am using this code as solution.
RowCollection.Where(row => row.Split(",").ToList()
.Where(x => list.Contains(x)).Any()).ToList();
And this is showing error.
Method 'System.String[] Split(Char[])' has no supported translation to SQL.
Please let me know the solution what will i do for this.
Unfortunately its the IQueryable you are using (Linq to SQL) that is not supporting the Split function.
You are really only left with the IEnumerable (Linq to Objects) support for it in this case. You second code snippet is what you need to do, or something like…
well in this case try out liek this
as split is not supported n t-sql you should first fetch data in one list and than apply your condition.
or apply
AsEnumerable()