Tag: linq
-
The LINQ expression OrderBy DateTimeOffset.DateTime could not be translated
0 I have a .NET Core project in which I have implemented this GraphQL query. The query works correctly, but the sorting by date is not working. [UsePaging(MaxPageSize = 200, IncludeTotalCount = true)] [UseProjection] [UseFiltering] [UseSorting] public async Task<IQueryable<UserDto>> UserMetadatas(string myValue, [Service] ActivityEngineDataContext context,[Service] IMapper mapper) { var entities = context.Users.Where(act => act.MyValue== myValue); return…
-
How to avoid manual inlining inside LINQ query to use as an expression and convert to SQL
0 I am trying to do some projections in LINQ to convert to DTOs. The goal is to do it with expressions so that it is translated directly to SQL. It works perfectly if I do everything inlined like this : return workHeader.Select(x => new WorkHeaderDto { Id = x.Id, StartDate = x.Works.Min(w => w.StartDate),…
-
How to combine `Select` and `Where`
7 I am doing something very simple and straightforward, and I cannot help but suspect / wish that it could be made a bit shorter. For the sake of the example, let us suppose that I have an IEnumerable<int?> and all I want is an IEnumerable<int> yielding only the non-null values. Here is some code…