我正在编写一个流利的 API(一直在升级 EntitySpaces),我想要这个语法......
EmployeeQuery q = new EmployeeQuery("q");
q.Select(q.Id > () => // Notice Func<> syntax here, this won't compile !!!!
{
return new EmployeeQuery("e", out var q1)
.Where(q1.Id.IsNotNull()).All();
})
);
但是你猜对了,编译错误。我重载了语法中的所有运算符,一切正常,但我无法让这个语法工作,我认为“>”后面跟着“()=>”语法只会完全混淆编译器,它永远无法真正工作?
请注意,上面的 Select() 方法中的“q.Id”返回一个 esQueryItem,因此下面的重载...
这是我的超载...
public class esQueryItem
{
public static esComparison operator >(esQueryItem item, Func<esDynamicQuery> func)
{
return null;
}
public static esComparison operator <(esQueryItem item, Func<esDynamicQuery> func)
{
return null;
}
}