Rohan Ramani

Rohan Ramani

  • NA
  • 786
  • 143.9k

How to copy one list to another list using linq?

Apr 15 2020 3:17 AM
Hi All I have two class
  1. public partial class UserMaster  
  2. {  
  3.         public Guid UserId { get; set; }  
  4.         public string FirstName { get; set; }  
  5.         public string LastName { get; set; }  
  6.         public string Email { get; set; }  
  7.         public int RoleId { get; set; }  
  8.         public bool Status { get; set; }  
  9.         public string PasswordSalt { get; set; }  
  10.         public string PasswordHash { get; set; }  
  11.         public DateTime CreatedDate { get; set; }  

 And
  1. public class RMangerViewModel  
  2. {  
  3.         public Guid UserId { getset; }  
  4.         public string FirstName { getset; }  
  5.         public string LastName { getset; }  

 Basically Manager is from UsereMaster but identify by RoleId=3.
I need to fill  RMangerViewModel  from UserMaster where RoleId = 3 using linq.
Note: List of UserMaster will be fill up by _context.UserMaster.
 
 

Answers (2)