Это в функции (создание IQueryable) ):
Код: Выделить всё
IQueryable queryable =
_aContext.AView
.FromSqlRaw(sql).AsNoTracking()
.OrderBy(linqOrderByClause)
.Select(x => new AvailableView()
{
Afield1 = x.Afield1
Afield2 = ConvertSomething(x.Afield2)
});
Код: Выделить всё
private static string ConvertSomething(string Afield2)
{
return Afield2;
}
Этот IQueryable выполняется в некотором классе «постраничного ответа», который мы создали, и когда придет время выполнить IQueryable, вот часть кода:
р>
Код: Выделить всё
ODataQuerySettings settings = new ODataQuerySettings();
// ODataQueryOptions options is passed into this function
if (options != null)
{
if (options.Filter != null)
{
queryable = options.Filter.ApplyTo(queryable, settings) as IQueryable;
}
if (options.OrderBy != null)
{
queryable = options.OrderBy.ApplyTo(queryable, settings) as IQueryable;
}
if (options.SelectExpand != null)
{
queryable = options.SelectExpand.ApplyTo(queryable, settings) as IQueryable;
}
}
List dataPage = queryable
.Skip(skip)
.Take(take)
.ToList();
Подробнее здесь: [url]https://stackoverflow.com/questions/78799902/c-sharp-net-core-6-0-iqueryable-odata-and-mapped-function-called-from-linq[/url]