LINQ to sql判断首字符是否为数字
linq to sql什么方法能对应数据库的ISNUMERIC不要.toList()之后的方法 --------------------编程问答-------------------- where SqlFunctions.Ascii(s.Abbreviation) >= '0' && SqlFunctions.Ascii(s.Abbreviation) <= '9' --------------------编程问答--------------------
--------------------编程问答--------------------
var query=from stu in db
where System.Text.RegularExpressions.Regex.IsMatch(stu.Filed<string>("StuID"), @"^[0-9]+.*?")
select stu;
ISNUMERIC 也判断不了首字母,这个就不错了
decimal.TryParse()对应ISNUMERIC --------------------编程问答-------------------- --------------------编程问答-------------------- SqlFunctions.ISNUMERIC
用这个 --------------------编程问答--------------------
List<string> list = null;
list.Where(item => char.IsDigit(item[0]));
判断是否为数字的方法可以看我的一篇文章:
http://blog.csdn.net/haukwong/article/details/8029946 --------------------编程问答-------------------- 以Northwind数据库中Orders表为例
其中字段ShipAddress为string类型
--------------------编程问答-------------------- 修改下:
var result = from u in entity.Orders
where u.ShipAddress.Length > 0 && Enumerable.Range(0, 9).Contains(u.ShipAddress[0])
select u;
--------------------编程问答--------------------
string[] strs = { "shen", "1sjd", "sdf2i3", "9sdjf" };
var result = from u in strs
where u.Length > 0 && new List<string> { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9"}.Contains(u[0].ToString())
select u;
Array.ForEach(result.ToArray(), s => Console.WriteLine(s));
这个就对了 用正则表达式 --------------------编程问答-------------------- http://stackoverflow.com/questions/558054/how-to-know-if-a-field-is-numeric-in-linq-to-sql
就可以使用sql的ISNUMERIC
补充:.NET技术 , LINQ