小编ban*_*n-G的帖子

使用Contains()时达到2100参数限制(SQL Server)

from f in CUSTOMERS
where depts.Contains(f.DEPT_ID)
select f.NAME
Run Code Online (Sandbox Code Playgroud)

deptsIEnumerable<int>部门ID 的列表()

这个查询工作正常,直到你传递一个大的列表(比如大约3000 dept ids)..然后我得到这个错误:

传入的表格数据流(TDS)远程过程调用(RPC)协议流不正确.此RPC请求中提供的参数太多.最高为2100.

我将查询更改为:

var dept_ids = string.Join(" ", depts.ToStringArray());
from f in CUSTOMERS
where dept_ids.IndexOf(Convert.ToString(f.DEPT_id)) != -1
select f.NAME
Run Code Online (Sandbox Code Playgroud)

使用IndexOf()修复错误但使查询变慢.有没有其他方法可以解决这个问题?非常感谢.

linq sql-server parameters limit

57
推荐指数
2
解决办法
6万
查看次数

Page_Init vs OnInit

在处理Page_Init事件或覆盖Page的OnInit方法之间,最好使用哪一个?谢谢.

asp.net

27
推荐指数
2
解决办法
3万
查看次数

将byte []转换为字符串

如何将字节数组转换为字符串?我需要获取原始内容,例如"96 = A8 = FC- = A8 = FE",但是当我使用说Encoding.UTF8.GetString(字节)时,它返回"96 - ".谢谢!

.net c#

2
推荐指数
1
解决办法
4412
查看次数

lambda到表达式树

如何将以下lambda转换为表达式树?

source.Join(lookup, s => s.Id, l => l.Id, (s,l) => l)
Run Code Online (Sandbox Code Playgroud)

我认为除了resultSelector(s,l)=> l之外,我已经涵盖了所有内容.

这是我的代码..谢谢!

public static IQueryable<TLookup> GetLookupSource<T, TLookup, TKey>(this IQueryable<T> source, IQueryable<TLookup> lookup{
   ParameterExpression s = Expression.Parameter(source.ElementType, "s");
   Expression<Func<T, TKey>> outerKeySelector = Expression.Lambda<Func<T, TKey>>(Expression.PropertyOrField(s, "Id"), s);

   ParameterExpression l = Expression.Parameter(lookup.ElementType, "l");
   Expression<Func<TLookup, TKey>> innerKeySelector = Expression.Lambda<Func<TLookup, TKey>>(Expression.PropertyOrField(l, "Id"), l);

   Expression<Func<T, TLookup, IQueryable<TLookup>>> resultSelector = null;//<---How to compose this

   MethodInfo joinMethod = typeof(Queryable).GetMethods(BindingFlags.Static | BindingFlags.Public).Where(m => m.Name == "Join" && m.GetParameters().Length == 5).First();
   var genericJoinMethod = joinMethod.MakeGenericMethod(typeof(T), typeof(TLookup), typeof(TKey), typeof(IQueryable<TLookup>)); …
Run Code Online (Sandbox Code Playgroud)

c# expression-trees

1
推荐指数
1
解决办法
397
查看次数

标签 统计

c# ×2

.net ×1

asp.net ×1

expression-trees ×1

limit ×1

linq ×1

parameters ×1

sql-server ×1