I have this string "1,2,3,4,5,6,7,8,9,10"
and I want to know if any number is in a table of database.
Example
Entity
public class MyNumber {
public string Numbers {get;set;}
}
MyNumber n = new MyNumber();
n.Numbers = "1,2,3,4,";
MyNumber n1 = new MyNumber();
n.Numbers = "5,6,7,8,9,10,"
context.MyNumbers.Add(n, n1);
context.SaveChanges();
//find numbers from a string of numbers
string _numbers = "10,11,12,15,"
//how to ?
var _myNum = context.MyNumbers.Where
.Select(x => x.Split(new string[]{","},StringSplitOptions.RemoveEmptyEntries))
.Where(x => _numbers.Split(new string[]{","},StringSplitOptions.RemoveEmptyEntries)
.Any(y => y.Equals(x)));
//no results
Debug.Writeline(_myNum.Count());
The string "_numbers" has the number 10 for example, and in database has the number "10", I would to know how could I find it using LINQ ?