Skip to content
Loading
  • 0
    And How to transfer the List<> data to databse
    0
  • Laxmidhar Sahoo
    0
    hey in foreach loop retrive trhe data from list and by adaptoper class or command class used for sending the data to data base
    0
  • Jignesh Kumar
    0
    Hey,
     
    Please try blow code,
     
    1. public class Product  
    2. {  
    3.     public string Id {get;set;}  
    4.     public string Name {get;set;}  
    5.     public int Price {get;set;}  
    6.     public int Qty {get;set;}  
    7. }  
    8.   
    9.     DbContext entities = new DbContext();  //Database connection string for Linq to DB
    10.     List<Product> productList = new List<Product>();  
    11.     productList = (from product in entities.Products  
    12.                        select product).Take(4)  
    13.                        .Select(x => new Product()  
    14.                                    {Id = x.Id  
    15.                                    ,Name = x.Name  
    16.                                    ,Price  = x.Price   
    17.                                    ,Qty  = x.Qty   
    18.                                    }).ToList();  
     
    0