private string BooksWithImagesDatabaseDump() { LocalDbRepository <Book> books; LocalDbRepository <Image> images; using (new DatabaseScope()) { books = new LocalDbRepository <Book>(new DbConfig(true)); images = new LocalDbRepository <Image>(new DbConfig(true)); Assert.IsFalse(books.ReposetoryCreated); Assert.IsFalse(images.ReposetoryCreated); } for (var i = 0; i < 3; i++) { var book = new Book(); books.Add(book); var image = new Image(); image.IdBook = book.BookId; images.Add(image); } var serializableContent = books.Database.GetSerializableContent(); var xmlSer = new XmlSerializer(typeof(DataContent)); using (var memStream = new MemoryStream()) { xmlSer.Serialize(memStream, serializableContent); var content = Encoding.ASCII.GetString(memStream.ToArray()); Assert.That(content, Is.Not.Null.And.Not.Empty); return(content); } }
public void ReadBooksWithImages() { _booksWithImagesDatabaseDump = BooksWithImagesDatabaseDump(); LocalDbRepository <Book> books; LocalDbRepository <Image> images; using (var scope = new DatabaseScope()) { var config = new DbConfig(true); books = new LocalDbRepository <Book>(config); images = new LocalDbRepository <Image>(config); scope.SetupDone += Scope_SetupDone; } Assert.That(books.Count, Is.EqualTo(3)); Assert.That(images.Count, Is.EqualTo(3)); CollectionAssert.AllItemsAreInstancesOfType(books, typeof(Book)); CollectionAssert.AllItemsAreNotNull(books); CollectionAssert.AllItemsAreUnique(books); CollectionAssert.AllItemsAreInstancesOfType(images, typeof(Image)); CollectionAssert.AllItemsAreNotNull(images); CollectionAssert.AllItemsAreUnique(images); Assert.That(books, Is.All.Property("BookId").Not.EqualTo(0).And.All.Property("BookName").Null); Assert.That(images, Is.All.Property("ImageId").Not.EqualTo(0) .And.All.Property("Text").Null .And.All.Property("IdBook").Not.EqualTo(0)); }
private string UsersDatabaseDump() { LocalDbRepository <Users> users; using (new DatabaseScope()) { users = new LocalDbRepository <Users>(new DbConfig(true)); Assert.IsFalse(users.ReposetoryCreated); } for (var i = 0; i < 3; i++) { var user = new Users(); users.Add(user); } var serializableContent = users.Database.GetSerializableContent(); var xmlSer = new XmlSerializer(typeof(DataContent)); using (var memStream = new MemoryStream()) { xmlSer.Serialize(memStream, serializableContent); var content = Encoding.ASCII.GetString(memStream.ToArray()); Assert.That(content, Is.Not.Null.And.Not.Empty); return(content); } }
public LocalDbRepository<Image> TestInit(IEnumerable<ILocalDbCheckConstraint<Image>> checks, IEnumerable<ILocalDbUniqueConstraint<Image>> unique, IEnumerable<ILocalDbDefaultConstraint<Image>> defaults) { LocalDbRepository<Image> images; using (new DatabaseScope()) { images = new LocalDbRepository<Image>(new DbConfig()); if (checks != null) foreach (var localDbCheckConstraint in checks) { images.Constraints.Check.Add(localDbCheckConstraint); } if (unique != null) foreach (var localDbCheckConstraint in unique) { images.Constraints.Unique.Add(localDbCheckConstraint); } if (defaults != null) foreach (var localDbCheckConstraint in defaults) { images.Constraints.Default.Add(localDbCheckConstraint); } } return images; }
public void Create() { using (new DatabaseScope()) { var dbConfig = new DbConfig(true); AppUsers = new LocalDbRepository <AppUserEntity>(dbConfig); UserData = new LocalDbRepository <UserDataEntity>(dbConfig); Roles = new LocalDbRepository <RoleEntity>(dbConfig); ChatGroups = new LocalDbRepository <ChatGroupEntity>(dbConfig); ChatMessages = new LocalDbRepository <ChatMessageEntity>(dbConfig); ChatGroupMap = new LocalDbRepository <ChatGroupUserMap>(dbConfig); var storeLocation = ConfigurationManager.AppSettings["SaveLocation"]; if (File.Exists(storeLocation)) { using (var fs = new FileStream(storeLocation, FileMode.Open)) { using (new TransactionScope()) { using (new ReplicationScope()) { new XmlSerializer(typeof(DataContent)).Deserialize(fs); } } } } } }
public LocalDbRepository <Image> TestInit(IEnumerable <ILocalDbCheckConstraint <Image> > checks, IEnumerable <ILocalDbUniqueConstraint <Image> > unique, IEnumerable <ILocalDbDefaultConstraint <Image> > defaults) { LocalDbRepository <Image> images; using (new DatabaseScope()) { images = new LocalDbRepository <Image>(new DbConfig(true)); if (checks != null) { foreach (var localDbCheckConstraint in checks) { images.Constraints.Check.Add(localDbCheckConstraint); } } if (unique != null) { foreach (var localDbCheckConstraint in unique) { images.Constraints.Unique.Add(localDbCheckConstraint); } } if (defaults != null) { foreach (var localDbCheckConstraint in defaults) { images.Constraints.Default.Add(localDbCheckConstraint); } } } return(images); }
public AdminController() { repo = new LocalDbRepository(); repo_data = new VisualDataRepository(ConfigurationManager.AppSettings["dbPath"]); repo_ext = new ExternalRepository(ConfigurationManager.AppSettings["dbPath"]); //Thread.CurrentThread.CurrentCulture. }
public void TestInit() { using (new DatabaseScope()) { _users = new LocalDbRepository<Users>(new DbConfig(), _useObjectCopy, null); } Assert.IsTrue(_users.ReposetoryCreated); }
private LocalDbRepository<Users> MockRepro() { LocalDbRepository<Users> users; using (var db = new DatabaseScope()) { users = new LocalDbRepository<Users>(new DbConfig()); } return users; }
public void TestInit() { using (new DatabaseScope()) { _books = new LocalDbRepository <Book>(new DbConfig(true)); _images = new LocalDbRepository <Image>(new DbConfig(true)); _imagesNullable = new LocalDbRepository <ImageNullable>(new DbConfig(true)); } }
public void TestInit() { using (new DatabaseScope()) { _users = new LocalDbRepository <Users>(new DbConfig(true), _useObjectCopy, null); } Assert.IsTrue(_users.ReposetoryCreated); }
public void TestInit() { using (new DatabaseScope()) { _books = new LocalDbRepository<Book>(new DbConfig()); _images = new LocalDbRepository<Image>(new DbConfig()); _imagesNullable = new LocalDbRepository<ImageNullable>(new DbConfig()); } }
private LocalDbRepository <Users> MockRepro() { LocalDbRepository <Users> users; using (var db = new DatabaseScope()) { users = new LocalDbRepository <Users>(new DbConfig(true)); } return(users); }
/// <summary> /// Initializes a new instance of the <see cref="ConstraintCollection{TEntity}" /> class. /// </summary> /// <param name="localDbRepository">The local database repository.</param> /// <param name="primaryKey">The primary key.</param> internal ConstraintCollection( LocalDbRepository <TEntity> localDbRepository, ILocalDbPrimaryKeyConstraint primaryKey) { _localDbRepository = localDbRepository; PrimaryKey = primaryKey; Unique = new UniqueConstrains <TEntity>(localDbRepository); Default = new DefaultConstraints <TEntity>(localDbRepository); Check = new CheckConstraints <TEntity>(localDbRepository); }
public void WriteBooksWithImages() { LocalDbRepository <Book> books; LocalDbRepository <Image> images; using (new DatabaseScope()) { books = new LocalDbRepository <Book>(new DbConfig(true)); images = new LocalDbRepository <Image>(new DbConfig(true)); Assert.IsFalse(books.ReposetoryCreated); Assert.IsFalse(images.ReposetoryCreated); } for (var i = 0; i < 3; i++) { var book = new Book(); books.Add(book); var image = new Image(); image.IdBook = book.BookId; images.Add(image); } var serializableContent = books.Database.GetSerializableContent(); var xmlSer = new XmlSerializer(typeof(DataContent)); using (var memStream = new MemoryStream()) { xmlSer.Serialize(memStream, serializableContent); var content = Encoding.ASCII.GetString(memStream.ToArray()); Assert.That(content, Is.Not.Null.And.Not.Empty); memStream.Seek(0, SeekOrigin.Begin); LocalDbRepository <Book> booksN; LocalDbRepository <Image> imagesN; using (new DatabaseScope()) { booksN = new LocalDbRepository <Book>(new DbConfig(true)); imagesN = new LocalDbRepository <Image>(new DbConfig(true)); Assert.IsFalse(booksN.ReposetoryCreated); Assert.IsFalse(imagesN.ReposetoryCreated); using (new TransactionScope()) { using (new ReplicationScope()) { xmlSer.Deserialize(memStream); } } } } }
public void TestInit() { using (new DatabaseScope()) { _books = new LocalDbRepository <Book>(new DbConfig(true)); _images = new LocalDbRepository <Image>(new DbConfig(true)); _imagesNullable = new LocalDbRepository <ImageNullable>(new DbConfig(true)); Assert.IsFalse(_books.ReposetoryCreated); Assert.IsFalse(_images.ReposetoryCreated); Assert.IsFalse(_imagesNullable.ReposetoryCreated); } Assert.IsTrue(_books.ReposetoryCreated); Assert.IsTrue(_images.ReposetoryCreated); Assert.IsTrue(_imagesNullable.ReposetoryCreated); }
public void TestInit() { using (new DatabaseScope()) { _books = new LocalDbRepository<Book>(new DbConfig()); _images = new LocalDbRepository<Image>(new DbConfig()); _imagesNullable = new LocalDbRepository<ImageNullable>(new DbConfig()); Assert.IsFalse(_books.ReposetoryCreated); Assert.IsFalse(_images.ReposetoryCreated); Assert.IsFalse(_imagesNullable.ReposetoryCreated); } Assert.IsTrue(_books.ReposetoryCreated); Assert.IsTrue(_images.ReposetoryCreated); Assert.IsTrue(_imagesNullable.ReposetoryCreated); }
public void ReadUsers() { _usersDatabaseDump = UsersDatabaseDump(); LocalDbRepository <Users> users; using (var scope = new DatabaseScope()) { users = new LocalDbRepository <Users>(new DbConfig(true)); scope.SetupDone += Scope_SetupDone1; } Assert.That(users.Count, Is.EqualTo(3)); Assert.That(users.ElementAt(0), Is.Not.Null.And.Property("UserID").EqualTo(1)); Assert.That(users.ElementAt(1), Is.Not.Null.And.Property("UserID").EqualTo(2)); Assert.That(users.ElementAt(2), Is.Not.Null.And.Property("UserID").EqualTo(3)); }
internal ReplicationNode(LocalDbRepository <TEntity> table, IReplicationNode <TEntity> duplication = null) { var table1 = table; var duplication1 = duplication; if (duplication != null) { For = new SequentialSequentialTriggerCollection <TEntity>(table1, duplication1.For); After = new SequentialSequentialTriggerCollection <TEntity>(table1, duplication1.After); InsteadOf = new TriggerInsteadtOfCollection <TEntity>(table1, duplication1.InsteadOf); } else { For = new SequentialSequentialTriggerCollection <TEntity>(table1); After = new SequentialSequentialTriggerCollection <TEntity>(table1); InsteadOf = new TriggerInsteadtOfCollection <TEntity>(table1); } }
public void WriteUsers() { LocalDbRepository <Users> users; using (new DatabaseScope()) { users = new LocalDbRepository <Users>(new DbConfig(true)); } users.Add(new Users()); users.Add(new Users()); users.Add(new Users()); var serializableContent = users.Database.GetSerializableContent(); var xmlSer = new XmlSerializer(typeof(DataContent)); using (var memStream = new MemoryStream()) { xmlSer.Serialize(memStream, serializableContent); var content = Encoding.ASCII.GetString(memStream.ToArray()); Assert.That(content, Is.Not.Null.And.Not.Empty); } }
/// <summary> /// Initializes a new instance of the <see cref="TriggerException{TEntity}" /> class. /// </summary> /// <param name="reason">The reason.</param> /// <param name="table">The table.</param> public TriggerException(string reason, LocalDbRepository <TEntity> table) : base("One trigger rejected the change. See reason.") { Reason = reason; _table = table; }
internal TriggerInsteadtOfCollection(LocalDbRepository <TEntity> tabel, ITriggerInsteadtOfCollection <TEntity> duplication = null) { _tabel = tabel; _duplication = duplication; }
/// <summary> /// Initializes a new instance of the <see cref="SequentialSequentialTriggerCollection{TEntity}" /> class. /// </summary> /// <param name="tabel">The tabel.</param> /// <param name="duplication">The duplication.</param> internal SequentialSequentialTriggerCollection(LocalDbRepository <TEntity> tabel, ISequentialTriggerCollection <TEntity> duplication = null) { Tabel = tabel; Duplication = duplication; }
public DbScope() { database = new DatabaseScope(); users = new LocalDbRepository <Users>(new DbConfig(true)); }
public AppointmentsService() { this._localDbRepository = new LocalDbRepository <Appointment>(); }
/// <summary> /// Initializes a new instance of the <see cref="DefaultConstraints{TEntity}" /> class. /// </summary> /// <param name="localDbRepository">The local database repository.</param> public DefaultConstraints(LocalDbRepository <TEntity> localDbRepository) { _constraints = new HashSet <ILocalDbDefaultConstraint <TEntity> >(new ConstraintComparer()); _localDbRepository = localDbRepository; }
public DbScope() { database = new DatabaseScope(); users = new LocalDbRepository<Users>(new DbConfig()); }
/// <summary> /// Initializes a new instance of the <see cref="UniqueConstrains{TEntity}" /> class. /// </summary> /// <param name="localDbRepository">The local database repository.</param> public UniqueConstrains(LocalDbRepository <TEntity> localDbRepository) { _constraints = new HashSet <ILocalDbUniqueConstraint <TEntity> >(); _localDbRepository = localDbRepository; }
/// <summary> /// Initializes a new instance of the <see cref="TriggerForTableCollection{TEntity}" /> class. /// </summary> /// <param name="table">The table.</param> internal TriggerForTableCollection(LocalDbRepository <TEntity> table) { _table = table; NotForReplication = new ReplicationNode <TEntity>(_table); WithReplication = new ReplicationNode <TEntity>(_table, NotForReplication); }
/// <summary> /// Initializes a new instance of the <see cref="InsteadtOfActionToken{TEntity}" /> class. /// </summary> /// <param name="item">The item.</param> /// <param name="table">The table.</param> public InsteadtOfActionToken(TEntity item, LocalDbRepository <TEntity> table) { Item = item; Table = table; }
public SpecialistsService() { this._localDbRepository = new LocalDbRepository <Specialist>(); }