Answers for "c# linq query map to entity"

C#
0

c# linq query map to entity

protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
    modelBuilder.Entity<User>().ToTable(tableName: "users");
    modelBuilder.Entity<WorkPlace>().ToTable(tableName: "workplaces");
    modelBuilder.Entity<User>()
        .HasRequired(user => user.Place)
        .WithMany(place => place.Users);
}
Posted by: Guest on November-18-2020
0

c# linq query map to entity

public List<CustomUser> GetActiveCustomuser()
{
    return context.Users
       .Where(u => u.Active)
       .Select(new CustomUser() 
           { 
               Name = u.Name, 
               Place = new CustomPlace() { Name = u.Place.Name }
           })
       .ToList();
}
Posted by: Guest on November-18-2020

C# Answers by Framework

Browse Popular Code Answers by Language