【发布时间】:2015-06-29 09:53:29
【问题描述】:
这会失败并出现错误:
private IQueryable<Field> PrepareAllFieldsQuery( ref DbGeography geo, int page, int amount, string sort, string order, ISearchCriteria searchCriteria )
{
var query = this.context.Fields
.Where( x => x.DeletedAt == null )
.OrderBy( x => x.GeoLocation.Distance( geo ) );
...
}
运行良好
private IQueryable<Field> PrepareAllFieldsQuery( DbGeography geo, int page, int amount, string sort, string order, ISearchCriteria searchCriteria )
{
var query = this.context.Fields
.Where( x => x.DeletedAt == null )
.OrderBy( x => x.GeoLocation.Distance( geo ) );
...
}
不同的是我的DbGeography这次没有被ref传递。
.OrderBy( x => x.GeoLocation.Distance( geo ) ); 函数会抛出以下错误的任何原因:
无法将 lambda 表达式转换为类型“字符串”,因为它不是委托类型
【问题讨论】:
-
我什至无法编译它... 不能在匿名方法、lambda 表达式或查询表达式中使用 ref 或 out 参数 'geo'
-
这可能post 似乎有解释。
-
@rdoubleui - 这很有意义。谢谢你。