Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

c# lambda get all records async

// Filter, sort, project it into the view model type and get the data as a list
var users = await allUsers.OrderBy(user => user.FirstName)
                             .Select(user => new UsersViewModel
    {
        Id = user.Id,
        UserName = user.UserName,
        FirstName = user.FirstName,
        LastName = user.LastName,
        DisplayName = user.DisplayName,
        Email = user.Email,
        Enabled = user.Enabled
    }).ToListAsync();

// now that we have the data, we iterate though it and 
// fetch the roles
var userViewModels = users.Select(async user => 
{
    user.Roles = string.Join(", ", await _userManager.GetRolesAsync(user))
});
Comment

PREVIOUS NEXT
Code Example
Csharp :: unity remove all child 
Csharp :: umbraco cannot start. a connection string is configured but umbraco cannot connect to the database. 
Csharp :: flutter failed asertion 
Csharp :: send to main args dotnet debug 
Csharp :: asp.net web hooks 
Csharp :: gridview column cell alignment form c# 
Csharp :: card caption 
Csharp :: initialization of dictionary in other forms c# 
Csharp :: c# restore form 
Csharp :: c# instantiation 
Csharp :: what is difference between int.Parse and toint32 in c# 
Csharp :: unity blender shadow messed up 
Csharp :: DotNet web Api Token based Authentication 
Csharp :: c# convert string to datetime any format 
Csharp :: hdrp lit change emmision values 
Csharp :: convert list of object linq 
Csharp :: C# devexpress get foucused dataRow of child gridView 
Csharp :: and in c# 
Csharp :: C# write to lines without extra line 
Csharp :: Delegates in UntiyC# 
Csharp :: An error occurred while deserializing the property of class Truncation resulted in data loss. 
Csharp :: c# remove 0 from string 
Csharp :: unity only one component type 
Csharp :: .NET TLS 1.3 example 
Csharp :: C# Project File Create 
Csharp :: vb.net how insert event inside an event 
Csharp :: c# project 
Csharp :: unity overlapspherenonalloc 
Csharp :: timespan format string c# 
Csharp :: c# windows forms function after load 
ADD CONTENT
Topic
Content
Source link
Name
1+1 =