View Single Post
  #7 (permalink)  
Old March 21st, 2015, 04:19 PM
mmorgan30 mmorgan30 is offline
Friend of Wrox
Points: 528, Level: 8
Points: 528, Level: 8 Points: 528, Level: 8 Points: 528, Level: 8
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Feb 2014
Posts: 136
Thanks: 1
Thanked 10 Times in 10 Posts
Default

as an example for the ErrorLogDB, I don't know all the details of the context so this purely example of entity frame and fetching and adding some data.

Code:


public Logs[] GetLogsBetween(DateTime start, DateTime end )
{
       Logs[] rVal = null;

      using( var db = new ErrorLogDBContext() )
      {
             rVal = db.LogTable.Where( r => r.LogTime >= start && r.LogTime <= end ).ToArray();
      }

      return rVal;
}


public void Log( Log log )
{
        using( var db = new ErrorLogDBContext() )
       {
            db.LogTable.Add(log)
            db.SaveChanges();
       }
}

use between ObjectContext and DBContext are slightly different but for the most part are the same (DBContext consumes an ObjectContext). the illustration above is of a DBContext

Last edited by mmorgan30; March 21st, 2015 at 04:30 PM.