Using EFCore with Identity for Core
By : Nitin
Date : March 29 2020, 07:55 AM
will help you For the last few days I've been fighting the Identity system in combination with Entity framework Core. Here's some information prior to revealing my problem: , The simplest way maybe to call UserManger.Users directly. Like this: code :
ApplicationUser user = await userManager.Users.Include(s => s.Sales).Where(e => e.Email == "t@t.net").FirstOrDefaultAsync();
|
.NetCore WebAPI methods Async or Not with EFCore query
By : Oli Warms
Date : March 29 2020, 07:55 AM
around this issue The benefits of async/await over regular, synchronized code, is biggest when your server is under heavy enough load that freeing up threads on the thread pool makes a difference. Before then, the overhead of context tracking and switching can easily be bigger than the performance gains of freeing up threads. I tend to favor using the asynchronous API over the synchronous, mainly because I've been in a few projects where high load and synchronous code was a high enough problem that someone decided it was time to refactor and move to async, and it was a pain every time. It's also becoming more and more common to only expose async API:s (for example, the Azure SDK has many async actions which don't have synchronous counterparts), which means that you might have to perform such a re-write later, if you end up using such an API. code :
public Task<string> ActuallySynchronousGetter()
{
return Task.FromResult("foo");
}
// note: no async/await, just Task<T>
public Task<string> ForwardingGetter()
{
return SomeOtherGetter(); // also with return type Task<string>
}
public async Task<string> GetStringAsynchronously()
{
var str = await SomeOtherGetter();
return str.Replace("foo", "bar"); // note: we need the actual string here
}
var data = await repository.Query()
.AsNoTracking()
.ProjectTo<UserViewModel>()
.Skip((page - 1) * pageSize)
.Take(pageSize)
.ToListAsync();
return new OkObjectResult(data);
|
Autosetting foreign key Ids for child objects in WebApi Rest actions bound for EFCore
By : Ginger
Date : March 29 2020, 07:55 AM
I hope this helps . I'm a little bit new to Dotnet core WebApi and Entity Framework so forgive me if I'm missing something super obvious. , Option 1 Maybe you should separate API Models and EF Models. code :
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
{
var results = new List<ValidationResult>();
// Do validation here, if there are errors add to the results
return results;
}
|
How to cache with EFCore in ASP.NET Core
By : sfk
Date : March 29 2020, 07:55 AM
|
What type of collection should be returned from EFCore 3.1 in WebAPI?
By : george
Date : September 22 2020, 08:00 PM
it fixes the issue Generally IEnumerable is a good choice to seal the results before send them to the request owner. Thus you can be sure that the collection did not change during the transmission. (by any mid-level function etc.) IAsyncEnumerable is also a good choice if you are planning to iterate the whole list immediately.
|