Linq To Sql Contains 参数数量最大不能超过 2100 怎么解决?

默认分类 未结 1 433
0扬风0
0扬风0 2023-03-20 05:31
相关标签:
1条回答
  • 2023-03-20 05:46

    LINQ to SQL will translate .NET methods in this manner:

    text.StartsWith(...)=LIKE ...%text.Contains(...)=LIKE %...%text.EndsWith(...)=LIKE %...

    var customers = (from stu in db.Customer where stu.rowguid.ToString().StartsWith("a") select stu).ToList(); foreach(var stu in customers) { Console.WriteLine(stu.PersonID + "," + stu.rowguid.ToString()); }

    Console.WriteLine("There are {0} rows data in table ", customers.Count); Console.ReadLine();

    linq,sqlmethods,like

    标签:

    分少点!回头入我团队帮我打工偿还呀!O(∩_∩)O哈哈~---------你根本不是级联的问题,而是要保持Contains方***能的特殊性,它有模糊匹配的功能!------第一种方式:轻装上阵,小集合拼合!var names = dataLst.Select(item => item.Name).Skip(1000).Take(1000);一千一次形成多集合合并do while--1000条目累加一次!cs+=db.InvoiceContracts.Where(item => names.Contains(item.Name)).Count() -----第二种:采用原始sql,这个比较实在。速度也较为理想。第三种:int csum=zero;// int csum=0;foreach (var item in names) { csum+= (from c in db.InvoiceContracts where SqlMethods.Like(c.Name, "%"+item+"%") select c).Count(); } -----------------因为本人写的东西说代码不是代码也不能运行,说伪码还有代码,应该一看就明白。可能不能运行,自己多调试,思路都有了!追问高手帮帮忙!rs = from item in rs join ci in db.CustomerInfos on item.Signer equals ci.User where ci.Type == query.CustomerType//定值 select item;这样设置关联的话 当customer表中存在 相同user的两条记录的时候我的结果集 就会多出一条重复的记录..因为这个生成的 INNER JOIN怎么样去写 才能避免这种情况啊?我不需要Customer里的任何数据.只是用它做中转 来设置查询条件.

    追答第一:除重。(from item in rs join ci in db.CustomerInfos on item.Signer equals ci.User where ci.Type == query.CustomerType//定值 select item).Distinct();第二:过滤对条件进行过滤,只取其一即可!第三:即使重复那是否影响最终结果集呢,不影响重复就重复呗!

    0 0~ 多用几次不就好了么~

    0 讨论(0)
提交回复