- Use the following method as reference to get the data from Database.
public List<tbl_M_EventLog> GetEventLog()
{
List<tbl_M_EventLog> objEventLog = null;
try
{
objEventLog = DBConnection.Entities.tbl_M_EventLog.OrderByDescending(T => T.EventLogId).ToList();
}
catch (Exception ex)
{
}
return objEventLog;
}
Showing posts with label Entity Framework. Show all posts
Showing posts with label Entity Framework. Show all posts
Tuesday, April 8, 2014
Get Data Using Entity Framework
Update Using Entity Framework
- Use the following method as a reference to update the record in Table using Entity Framework.
public bool UpdateEventLog(tbl_M_EventLog objNewEventLog)
{
bool status = false;
try
{
tbl_M_EventLog objEventLog = DBConnection.Entities.tbl_M_EventLog.SingleOrDefault(p => p.EventId == objNewEventLog.EventId);
DBConnection.Entities.ObjectStateManager.ChangeObjectState(objEventLog, System.Data.EntityState.Modified);
DBCommon.ReflectSingleData(objEventLog, objNewEventLog, true);
DBConnection.Entities.SaveChanges();
DBConnection.SaveChanges();
status = true;
}
catch (Exception ex)
{
}
return status;
}
Insert Using Entity Framework
- Use the following method as a reference to insert a new record in Table.
public long InsertEventLog(tbl_M_EventLog objEventLog)
{
long EventId=0;
try
{
DBConnection.Entities.AddTotbl_M_EventLog(objEventLog);
DBConnection.SaveChanges();
EventId = objEventLog.EventId;
}
catch (Exception ex)
{
}
return EventId;
}
Create Using Entity Framework in Asp .Net
Please follow the below steps to create Entities.
- Right click on Solution Explorer. And Click on Add New Item. Then Select ADO.NET Entity Data Model.
- Then select Generate Data From Database.
- Then choose your database Objects to create the entities.
- Then you will see the selected objects on the Entity file.
Subscribe to:
Posts (Atom)



