Beispiel #1
0
        public void Init()
        {
            Entities = new EntityInfoCollection();
            var factory = new Mock <IFieldPropertyFactory>();

            Entity = EntityInfo.Create(factory.Object, Entities, typeof(Author));
        }
Beispiel #2
0
        public void SetUp()
        {
            var entityCollection = new EntityInfoCollection();
            var factory          = new Mock <IFieldPropertyFactory>();

            BookVersionEntityInfo = EntityInfo.Create(factory.Object, entityCollection, typeof(BookVersion));
        }
Beispiel #3
0
 public ForeignKey(EntityInfoCollection entities, IEntityInfo entityLocal, PropertyInfo prop,
                   ForeignKeyAttribute foreignKeyAttribute)
     : base(entityLocal, prop, foreignKeyAttribute)
 {
     _constraintName = new Lazy <string>(ComputeConstraintName);
     Entities        = entities;
     ForeignType     = foreignKeyAttribute.ForeignType;
 }
Beispiel #4
0
        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);
        }
Beispiel #5
0
        public static EntityInfo GetEntityInfo(EntityInfoCollection entities, string entityName)
        {
            EntityInfo entityInfo = entities.GetByName(entityName);

            if (entityInfo != null)
            {
                return(entityInfo);
            }
            return(StandardEntityInfo(entityName));
        }
Beispiel #6
0
        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);
        }
Beispiel #7
0
        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);
        }
Beispiel #8
0
 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>();
 }
Beispiel #9
0
        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);
        }
Beispiel #10
0
        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);
                    }
                }
            }
        }
Beispiel #12
0
        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);
        }
Beispiel #13
0
 public FilterFactory(ISqlFactory sqlFactory, EntityInfoCollection entities)
 {
     _sqlFactory = sqlFactory;
     _entities   = entities;
 }
Beispiel #14
0
 public Selectable(IDataStore datastore, EntityInfoCollection entities, Type entityInvolve)
 {
     Datastore = datastore;
     Query     = new QuerySet(entities, entityInvolve);
 }
Beispiel #15
0
 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);
             }
         }
     }
 }
Beispiel #17
0
 public static ForeignKey Create(EntityInfoCollection entities, IEntityInfo entityLocal, PropertyInfo prop,
                                 ForeignKeyAttribute foreignKeyAttribute)
 {
     return(new ForeignKey(entities, entityLocal, prop, foreignKeyAttribute));
 }
Beispiel #18
0
 public FilterBuilder(EntityInfoCollection entityInfos, IFilterFactory filterFactory, LambdaExpression exp)
 {
     _entityInfos   = entityInfos;
     _filterFactory = filterFactory;
     _expression    = exp;
 }