public void CodeFirst_IDisposable_Constructor_Test() { var stopwatch = Stopwatch.StartNew(); using (var target = new CodeFirstDataContext()) { // do nothing } StopAndPrint(stopwatch); }
public void CodeFirst_Constructor_Test() { // arrange var stopwatch = Stopwatch.StartNew(); // act var target = new CodeFirstDataContext(); // assert StopAndPrint(stopwatch); }
public void CodeFirst_FetchFirstRecord() { // arrange var stopwatch = Stopwatch.StartNew(); // act var context = new CodeFirstDataContext(); var target = context.Customers.FirstOrDefault(); // assert target.Should().NotBeNull(); target.CustomerID.Should().BeGreaterOrEqualTo(1); StopAndPrint(stopwatch); }
public void CodeFirst_FetchSingleRecord() { // arrange var customerId = 1; var stopwatch = Stopwatch.StartNew(); // act var context = new CodeFirstDataContext(); var target = context.Customers.SingleOrDefault(c => c.CustomerID == customerId); // assert target.Should().NotBeNull(); target.CustomerID.Should().Be(customerId); StopAndPrint(stopwatch); }
static void Main(string[] args) { using (var codeFirstContext = new CodeFirstDataContext()) { var cfMessages = codeFirstContext.Messages.Include(m => m.User); Console.WriteLine(cfMessages.ToList().Count); } using (var dbFirstContext = new DbFirstEntities()) { var dbfMessages = dbFirstContext.Messages.Include(m => m.User); Console.WriteLine(dbfMessages.ToList().Count); } Console.ReadLine(); }
public UserServices(CodeFirstDataContext context, IMapper mapper) { _context = context; _mapper = mapper; }
public static void Initialize(CodeFirstDataContext _context) { _context.Database.Migrate(); }
public CategoryServices(CodeFirstDataContext context, IMapper mapper) { _context = context; _mapper = mapper; }