0
有人能告诉我如何返回IQueryable<T>
?如何返回IQueryable <T>
我越来越:
无法隐式转换类型
System.Linq.IQueryable<object>
到System.Linq.IQueryable<TType>
。一个显式转换存在(被 缺少强制转换?)
预先感谢您
代码:
public IQueryable<TType> ExecuteScript<TType>(string script, object parameters) where TType : class, new()
{
string typeName = String.Empty;
LuaScript lScript = LuaScript.Prepare(script);
var lLScript = lScript.Load(Context.Server());
//Converts returned result into a string array.
var result = (string[])lLScript.Evaluate(Context.Database(), parameters);
if (result.Any())
{
_dataValue = new SortedDictionary<string, string>();
int i=0;
while(i < result.Count())
{
_dataValue.Add(result[i], result[i+=1]);
i++;
}
}
IQueryable<object> query = _dataValue.AsQueryable().Select(r => r.Value);
return query;
}
你为什么要返回IQueryable的''?数据在内存中,为什么不让它成为'IEnumerable '?调用'.AsQueryable()'的原因极其有限。 –
Enigmativity