Gautam Buddha Temple Varanasi,Varanasi - Buddhist Pilgrimage

Wednesday, August 14, 2013

Add new record in database usinbg Entity Framework/Entity Framework - Inserting Data to Database

 For adding new objects to the Entity Set, you need to create an instance of an Entity type and add the object to the object context.   
 public bool StudentDetail(StudentDetail objstudetail)  
       StudentDetail studetail = new StudentDetail();  
       studetail.ID = objstudetail.ID;  
       studetail.Name = objstudetail.Name;  
       studetail.Age = objstudetail.Age;  
       studetail.Address = objstudetail.Address;  
       studetail.City = objstudetail.City;  
           using (DBEntities context = new DBEntities())  
       catch (Exception ex)  
        throw ex;  
       return true;  

No comments:

Post a Comment