ef-core-3.0

EF Core 3.0 - Convert SQL to LINQ

放肆的年华 提交于 2021-01-27 10:49:19
问题 The example given in the blog has the following from e in s.StudentCourseEnrollments where courseIDs.Contains(e.Course.CourseID) select e The contains logic will not work when we are looking for an exact match. If a student has enrolled for 6 courses (ex : 1,2,3,4,5,6) and the requested list contains 5 (ex: 1,2,3,4,5) the query will return a match when it should not. The other way works well when the student has enrolled in a subset of the requested list. Below solution works but need help to

EF Core 3.0 - Convert SQL to LINQ

て烟熏妆下的殇ゞ 提交于 2021-01-27 10:48:29
问题 The example given in the blog has the following from e in s.StudentCourseEnrollments where courseIDs.Contains(e.Course.CourseID) select e The contains logic will not work when we are looking for an exact match. If a student has enrolled for 6 courses (ex : 1,2,3,4,5,6) and the requested list contains 5 (ex: 1,2,3,4,5) the query will return a match when it should not. The other way works well when the student has enrolled in a subset of the requested list. Below solution works but need help to

How to use Pomelo.EntityFrameworkCore.MySql provider for ef core 3 in async mode properly?

为君一笑 提交于 2021-01-07 03:56:03
问题 We are building an asp.net core 3 application which uses ef core 3.0 with Pomelo.EntityFrameworkCore.MySql provider 3.0. Right now we are trying to replace all database calls from sync to async, like: //from dbContext.SaveChanges(); //to await dbContext.SaveChangesAsync(); Unfortunetly when we do it we expereince two issues: Number of connections to the server grows significatntly compared to the same tests for sync calls Average processing speed of our application drops significantly What is

How to use Pomelo.EntityFrameworkCore.MySql provider for ef core 3 in async mode properly?

☆樱花仙子☆ 提交于 2021-01-07 03:55:09
问题 We are building an asp.net core 3 application which uses ef core 3.0 with Pomelo.EntityFrameworkCore.MySql provider 3.0. Right now we are trying to replace all database calls from sync to async, like: //from dbContext.SaveChanges(); //to await dbContext.SaveChangesAsync(); Unfortunetly when we do it we expereince two issues: Number of connections to the server grows significatntly compared to the same tests for sync calls Average processing speed of our application drops significantly What is

How to make parallel async queries in EF Core 3.0 with repository pattern?

岁酱吖の 提交于 2020-12-11 09:10:03
问题 I have repository like public interface IEmployeeRepository { Task<EmployeeSettings> GetEmployeeSettings(int employeeId); Task<ICollection<DepartmentWorkPosition>> GetWorkPositions(int employeeId); } Constructor of repository (DbContext injection): public EmployeeRepository(EmployeeDbContext dbContext) { _dbContext = dbContext; } And call it in EF Core 2.0 like var settingsTask = _employeeRepository .GetEmployeeSettings(employeeId.Value); var workPositionsTask = _employeeRepository

How to make parallel async queries in EF Core 3.0 with repository pattern?

前提是你 提交于 2020-12-11 09:09:57
问题 I have repository like public interface IEmployeeRepository { Task<EmployeeSettings> GetEmployeeSettings(int employeeId); Task<ICollection<DepartmentWorkPosition>> GetWorkPositions(int employeeId); } Constructor of repository (DbContext injection): public EmployeeRepository(EmployeeDbContext dbContext) { _dbContext = dbContext; } And call it in EF Core 2.0 like var settingsTask = _employeeRepository .GetEmployeeSettings(employeeId.Value); var workPositionsTask = _employeeRepository

How to make parallel async queries in EF Core 3.0 with repository pattern?

你说的曾经没有我的故事 提交于 2020-12-11 09:07:43
问题 I have repository like public interface IEmployeeRepository { Task<EmployeeSettings> GetEmployeeSettings(int employeeId); Task<ICollection<DepartmentWorkPosition>> GetWorkPositions(int employeeId); } Constructor of repository (DbContext injection): public EmployeeRepository(EmployeeDbContext dbContext) { _dbContext = dbContext; } And call it in EF Core 2.0 like var settingsTask = _employeeRepository .GetEmployeeSettings(employeeId.Value); var workPositionsTask = _employeeRepository

How to make parallel async queries in EF Core 3.0 with repository pattern?

心不动则不痛 提交于 2020-12-11 09:07:19
问题 I have repository like public interface IEmployeeRepository { Task<EmployeeSettings> GetEmployeeSettings(int employeeId); Task<ICollection<DepartmentWorkPosition>> GetWorkPositions(int employeeId); } Constructor of repository (DbContext injection): public EmployeeRepository(EmployeeDbContext dbContext) { _dbContext = dbContext; } And call it in EF Core 2.0 like var settingsTask = _employeeRepository .GetEmployeeSettings(employeeId.Value); var workPositionsTask = _employeeRepository

How to make parallel async queries in EF Core 3.0 with repository pattern?

末鹿安然 提交于 2020-12-11 09:06:09
问题 I have repository like public interface IEmployeeRepository { Task<EmployeeSettings> GetEmployeeSettings(int employeeId); Task<ICollection<DepartmentWorkPosition>> GetWorkPositions(int employeeId); } Constructor of repository (DbContext injection): public EmployeeRepository(EmployeeDbContext dbContext) { _dbContext = dbContext; } And call it in EF Core 2.0 like var settingsTask = _employeeRepository .GetEmployeeSettings(employeeId.Value); var workPositionsTask = _employeeRepository

Iterating an IAsyncEnumerable in a function returning an IAsyncEnumerable with cancellation

◇◆丶佛笑我妖孽 提交于 2020-12-09 05:10:39
问题 As the title says, I have to following function: public async IAsyncEnumerable<Job> GetByPipeline(int pipelineId, [EnumeratorCancellation] CancellationToken cancellationToken = default) { await foreach (var job in context.Jobs.Where(job => job.Pipeline.Id == pipelineId) .AsAsyncEnumerable() .WithCancellation(cancellationToken) .ConfigureAwait(false)) { yield return job; } } I have trouble wrapping my head around where the cancellation token is going, and a nagging feeling that I am using it