using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Threading; using System.Threading.Tasks; using AsbCloudApp.Data; using AsbCloudApp.Services; using AsbCloudDb.Model; using AsbCloudInfrastructure; using CliWrap; using Mapster; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.DependencyInjection; namespace ConsoleApp1 { class Program { static void Main(/*string[] args*/) { var db = ServiceFactory.Context; var q = db.TelemetryDataSaub .Select(t => new { t.IdTelemetry, t.DateTime, t.WellDepth, }) .GroupBy(t => t.IdTelemetry) .Select(g => new { Id = g.Key, First = g.OrderBy(t => t.DateTime).FirstOrDefault(), Last = g.OrderBy(t => t.DateTime).LastOrDefault(), }); var d = q.AsNoTracking().ToArray(); } } }