Can someone tell me how I can return an IQueryable<T>?
I am getting :
Cannot implicitly convert type
System.Linq.IQueryable<object>toSystem.Linq.IQueryable<TType>. An explicit conversion exists (are you missing a cast?)
Thank you in advance
Code:
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;
}
You try to return IQueryable<object> from:
IQueryable<object> query = _dataValue.AsQueryable().Select(r => r.Value);
return query;
But function return type is IQueryable<TType> from:
public IQueryable<TType> ExecuteScript<TType>(string script, object parameters) where TType : class, new()
Try:
IQueryable<TType> query = _dataValue.AsQueryable().Select(r => r.Value);
return query;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With