接受具有 Func 重载的 Expression 参数的方法的 IntelliSense
IntelliSense for method accepting Expression parameter with Func overload
ServiceStack OrmLite 的Select 方法可以接受Expression<Func<MyTable,bool>>
作为参数。它还可以接受 Func
作为参数。我更喜欢使用 Expression 参数,但 VisualStudio 的智能感知总是认为我输入的是 Func 参数:
var connstr = @"Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=mydb";
var factory = new OrmLiteConnectionFactory(connstr, SqlServerDialect.Provider);
using (var db = factory.Open())
{
// using the Func<<SqlExpressionVisitor<MyTable>,SqlExpressionVisitor<MyTable>> overload
var withvisitor = db.Select<MyTable>(v => v.Where(t => t.ID == 42));
// using the Expression<Func<MyTable,bool>> overload
// but the intellisense is still for the Func overload
var withoutvisitor = db.Select<MyTable>(t => t.ID == 42);
}
有没有办法告诉 VisualStudio 我想使用表达式重载而不是 Func 重载(用于智能感知)?
使用Visual Studio 2015。它足够聪明,可以检测到您打算输入表达式。
ServiceStack OrmLite 的Select 方法可以接受Expression<Func<MyTable,bool>>
作为参数。它还可以接受 Func
作为参数。我更喜欢使用 Expression 参数,但 VisualStudio 的智能感知总是认为我输入的是 Func 参数:
var connstr = @"Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=mydb";
var factory = new OrmLiteConnectionFactory(connstr, SqlServerDialect.Provider);
using (var db = factory.Open())
{
// using the Func<<SqlExpressionVisitor<MyTable>,SqlExpressionVisitor<MyTable>> overload
var withvisitor = db.Select<MyTable>(v => v.Where(t => t.ID == 42));
// using the Expression<Func<MyTable,bool>> overload
// but the intellisense is still for the Func overload
var withoutvisitor = db.Select<MyTable>(t => t.ID == 42);
}
有没有办法告诉 VisualStudio 我想使用表达式重载而不是 Func 重载(用于智能感知)?
使用Visual Studio 2015。它足够聪明,可以检测到您打算输入表达式。