public void TestMethodGetAllStudent() { context = new SampleDbEntities(); unitOfWork = new UnitOfWork(); studentRepository = new StudentRepository(context); studentService = new StudentService(unitOfWork, studentRepository); stud = new Student(); int nb = studentService.GetAll().ToList().Count(); //stud = studentService.GetById(i); Assert.AreEqual(3, nb); }
public void TestDeleteStudent() { context = new SampleDbEntities(); unitOfWork = new UnitOfWork(); studentRepository = new StudentRepository(context); studentService = new StudentService(unitOfWork, studentRepository); stud = studentService.GetById(16); using (var dbContextTransaction = context.Database.BeginTransaction()) { studentService.Delete(stud); dbContextTransaction.Rollback(); } }
public void GetInfoGrid() { using (var context = new SampleDbEntities()) { var students = (from stud in context.Students select new { stud.Id, stud.FirstName, stud.LastName, stud.Email, stud.EnrollmentNumber, Department = stud.Departement.Title }).ToList(); } }
public void TestUpdateStudent() { string updatedName = "name updated"; context = new SampleDbEntities(); unitOfWork = new UnitOfWork(); studentRepository = new StudentRepository(context); studentService = new StudentService(unitOfWork, studentRepository); stud = studentService.GetById(16); stud.FirstName = updatedName; using (var dbContextTransaction = context.Database.BeginTransaction()) { studentService.Update(stud); dbContextTransaction.Rollback(); } }
public void TestInsertStudent() { context = new SampleDbEntities(); unitOfWork = new UnitOfWork(); studentRepository = new StudentRepository(context); studentService = new StudentService(unitOfWork, studentRepository); stud = new Student() { FirstName = "test name", LastName = "last name", Email = "*****@*****.**", EnrollmentNumber = "123456", AddedDate = DateTime.ParseExact("2017-12-07 14:40:52,531", "yyyy-MM-dd HH:mm:ss,fff", System.Globalization.CultureInfo.InvariantCulture), ModifiedDate = DateTime.ParseExact("2017-12-07 14:40:52,531", "yyyy-MM-dd HH:mm:ss,fff", System.Globalization.CultureInfo.InvariantCulture) }; using (var dbContextTransaction = context.Database.BeginTransaction()) { studentService.Create(stud); dbContextTransaction.Rollback(); } }
private void GetColumNames() { ColumnNames = new List <string>(); using (SampleDbEntities context = new SampleDbEntities()) { var objectContext = ((IObjectContextAdapter)context).ObjectContext; var storageMetadata = ((EntityConnection)objectContext.Connection).GetMetadataWorkspace().GetItems(DataSpace.SSpace); var entityProps = (from sm in storageMetadata where sm.BuiltInTypeKind == BuiltInTypeKind.EntityType select sm as EntityType); // For your project, open the model browser to get the name for the model, will have namespace.Store var metaData = typeof(Student).GetProperties() .Select(property => property.Name) .ToArray(); //var metaData = (from m in entityProps where m.FullName == "NORTHWNDModel.Store.Customers" select m.DeclaredProperties).ToList(); foreach (var topItem in metaData) { foreach (var item in topItem) { ColumnNames.Add(item.ToString()); } } } }
public UnitOfWork() { context = new SampleDbEntities(); }
public UnitOfWork(SampleDbEntities context) { this.context = context; }
public OrderRepository(SampleDbEntities dbContext) { _dbContext = dbContext; }
public DepartementRepository(SampleDbEntities context) : base(context) { }
public Repository(SampleDbEntities context) { this.context = context; }
public HurricanesController() { _context = new SampleDbEntities(); }
public StudentRepository(SampleDbEntities context) : base(context) { }
public CustomerRepository(SampleDbEntities dbContext) { _dbContext = dbContext; }
public ContactsRepositoryWithUow(SampleDbEntities _entities) { entities = _entities; }