public void Init() { Entities = new EntityInfoCollection(); var factory = new Mock <IFieldPropertyFactory>(); Entity = EntityInfo.Create(factory.Object, Entities, typeof(Author)); }
public void SetUp() { var entityCollection = new EntityInfoCollection(); var factory = new Mock <IFieldPropertyFactory>(); BookVersionEntityInfo = EntityInfo.Create(factory.Object, entityCollection, typeof(BookVersion)); }
public ForeignKey(EntityInfoCollection entities, IEntityInfo entityLocal, PropertyInfo prop, ForeignKeyAttribute foreignKeyAttribute) : base(entityLocal, prop, foreignKeyAttribute) { _constraintName = new Lazy <string>(ComputeConstraintName); Entities = entities; ForeignType = foreignKeyAttribute.ForeignType; }
public void CreateEntity_PrimaryKeyShouldInitialize() { var entities = new EntityInfoCollection(); var factory = new Mock <IFieldPropertyFactory>(); var entityInfo = EntityInfo.Create(factory.Object, entities, typeof(Book)); Assert.IsNotNull(entityInfo.PrimaryKey); Assert.AreEqual("ORM_PK_Book", entityInfo.PrimaryKey.ConstraintName); }
public static EntityInfo GetEntityInfo(EntityInfoCollection entities, string entityName) { EntityInfo entityInfo = entities.GetByName(entityName); if (entityInfo != null) { return(entityInfo); } return(StandardEntityInfo(entityName)); }
public void CreateTombstone_PrimaryKeyShouldHaveKeySchemToNone() { var entities = new EntityInfoCollection(); var factory = new Mock <IFieldPropertyFactory>(); var entityInfo = EntityInfo.Create(factory.Object, entities, typeof(EntitySync)); var entitySync = SyncEntity.Create(entityInfo); var tombstoneEntityInfo = entitySync.CreateEntityTombstone(); Assert.AreEqual(KeyScheme.None, tombstoneEntityInfo.PrimaryKey.KeyScheme); }
public void Setup() { Store = new Mock <ISqlDataStore>(); Observer = new Mock <IOrmObserver>(); var entities = new EntityInfoCollection(); EntityInfo.Create(new Mock <IFieldPropertyFactory>().Object, entities, typeof(ConcreteEntity)); Store.Setup(_ => _.Entities).Returns(entities); Repository = new Repository <ConcreteEntity, ConcreteEntity>(Store.Object); }
internal QuerySet(EntityInfoCollection entities, Type entityInvolve) { _where = new Where(); _orderBy = new OrderBy(); _groupBy = new GroupBy(); Entities = entities; EntityInvolve = new Dictionary <string, IEntityInfo>(); Entity = AddInvolveEntity(entityInvolve); JoinList = new List <IJoin>(); }
public void CreateEntity_ForeignKeyShouldInitialize() { var entities = new EntityInfoCollection(); var factory = new Mock <IFieldPropertyFactory>(); EntityInfo.Create(factory.Object, entities, typeof(Book)); var entityInfo = EntityInfo.Create(factory.Object, entities, typeof(BookVersion)); Assert.AreEqual(1, entityInfo.ForeignKeys.Count); Assert.AreEqual("ORM_FK_BookVersion_Book", entityInfo.ForeignKeys[0].ConstraintName); }
public void Init() { Entities = new EntityInfoCollection(); var factory = new Mock <IFieldPropertyFactory>(); Entity = EntityInfo.Create(factory.Object, Entities, typeof(Author)); SqlFactory = new Mock <ISqlFactory>(); FilterFactory = new FilterFactory(SqlFactory.Object, Entities); Params = new List <IDataParameter>(); SqlFactory.Setup( _ => _.AddParam(It.IsAny <object>(), Params) ).Returns(SqlValue); }
private void RecurseCreation(object item, EntityInfoCollection <EntityInfo> entities) { Random rand = new Random(DateTime.Now.Millisecond * DateTime.Now.Minute); string entityName = entities.GetNameForType(item.GetType()); if (entities.HasEntity(entityName) && entities[entityName].References.Count > 0) { object primarykey = entities[entityName].Fields.KeyField.PropertyInfo.GetValue(item, null); foreach (var refentity in entities[entityName].References) { if (this._stopGenerator) { break; } var genType = typeof(List <>).MakeGenericType(refentity.ReferenceEntityType); var items = (System.Collections.IList)Activator.CreateInstance(genType); Model.modelbase reference = (Model.modelbase)Activator.CreateInstance(refentity.ReferenceEntityType); int iCount = rand.Next(this._config.GenerateChildrenBaseAmount); for (int i = 0; i < iCount; i++) { if (this._stopGenerator) { break; } var newelement = reference.CreateRandomObject(primarykey); AddMessage(newelement.ToString()); items.Add(newelement); //this._DataStore.Insert(newelement); RecurseCreation(newelement, entities); } if (refentity.IsArray) { var arr = Array.CreateInstance(refentity.ReferenceEntityType, items.Count); items.CopyTo(arr, 0); refentity.PropertyInfo.SetValue(item, arr, null); } else if (refentity.IsList) { refentity.PropertyInfo.SetValue(item, items, null); } else { refentity.PropertyInfo.SetValue(item, items[0], null); } } } }
public void Init() { var entityCollection = new EntityInfoCollection(); var factory = new Mock <IFieldPropertyFactory>(); EntityInfo.Create(factory.Object, entityCollection, typeof(Author)); EntityInfo.Create(factory.Object, entityCollection, typeof(Book)); BookVersionEntityInfo = EntityInfo.Create(factory.Object, entityCollection, typeof(BookVersion)); var dataStore = new Mock <IDataStore>(); var sqlFactory = new Mock <ISqlFactory>(); var param = new Mock <IDataParameter>(); sqlFactory.Setup(_ => _.CreateParameter()).Returns(param.Object); dataStore.Setup(_ => _.SqlFactory).Returns(sqlFactory.Object); SqlQuery = new Selectable <Author>(dataStore.Object, entityCollection); }
public FilterFactory(ISqlFactory sqlFactory, EntityInfoCollection entities) { _sqlFactory = sqlFactory; _entities = entities; }
public Selectable(IDataStore datastore, EntityInfoCollection entities, Type entityInvolve) { Datastore = datastore; Query = new QuerySet(entities, entityInvolve); }
public Selectable(IDataStore datastore, EntityInfoCollection entities) { Datastore = datastore; Query = new QuerySet(entities, typeof(TIEntity)); }
private void RecurseCreation(object item, EntityInfoCollection<EntityInfo> entities) { Random rand = new Random(DateTime.Now.Millisecond * DateTime.Now.Minute); string entityName = entities.GetNameForType(item.GetType()); if (entities.HasEntity(entityName) && entities[entityName].References.Count > 0) { object primarykey = entities[entityName].Fields.KeyField.PropertyInfo.GetValue(item, null); foreach (var refentity in entities[entityName].References) { if (this._stopGenerator) break; var genType = typeof(List<>).MakeGenericType(refentity.ReferenceEntityType); var items = (System.Collections.IList)Activator.CreateInstance(genType); Model.modelbase reference = (Model.modelbase)Activator.CreateInstance(refentity.ReferenceEntityType); int iCount = rand.Next(this._config.GenerateChildrenBaseAmount); for (int i = 0; i < iCount; i++) { if (this._stopGenerator) break; var newelement = reference.CreateRandomObject(primarykey); AddMessage(newelement.ToString()); items.Add(newelement); //this._DataStore.Insert(newelement); RecurseCreation(newelement, entities); } if (refentity.IsArray) { var arr = Array.CreateInstance(refentity.ReferenceEntityType, items.Count); items.CopyTo(arr, 0); refentity.PropertyInfo.SetValue(item, arr, null); } else if (refentity.IsList) { refentity.PropertyInfo.SetValue(item, items, null); } else { refentity.PropertyInfo.SetValue(item, items[0], null); } } } }
public static ForeignKey Create(EntityInfoCollection entities, IEntityInfo entityLocal, PropertyInfo prop, ForeignKeyAttribute foreignKeyAttribute) { return(new ForeignKey(entities, entityLocal, prop, foreignKeyAttribute)); }
public FilterBuilder(EntityInfoCollection entityInfos, IFilterFactory filterFactory, LambdaExpression exp) { _entityInfos = entityInfos; _filterFactory = filterFactory; _expression = exp; }