Exemplo n.º 1
0
        private DynamicFunctionWithParam InnerJoinFor(dynamic model)
        {
            return((options) =>
            {
                if (EagerLoadMany.ShouldDiscardCache(options))
                {
                    EagerLoadMany.Cache = null;
                }

                if (EagerLoadMany.Cache != null)
                {
                    return EagerLoadMany.Cache;
                }

                string innerJoinSelectClause = InnerJoinSelectClause(XRefFromColumn, toTable, throughTable, XRefToColumn, ToTableColumn, PropertyContainingIdValue, model);

                var models = (Repository.Query(innerJoinSelectClause) as IEnumerable <dynamic>).ToList();

                foreach (var m in models)
                {
                    AddReferenceBackToModel(m, model);
                }

                EagerLoadMany.Cache = new DynamicModels(models);

                EagerLoadMany.Cache.SetMember("New", NewItemDelegate());

                AddRepository(EagerLoadMany.Cache, new DynamicRepository(throughTable));

                return EagerLoadMany.Cache;
            });
        }
Exemplo n.º 2
0
        private DynamicFunctionWithParam InnerJoinFor(dynamic model)
        {
            return((options) =>
            {
                if (EagerLoadMany.ShouldDiscardCache(options))
                {
                    EagerLoadMany.Cache = null;
                }

                if (EagerLoadMany.Cache != null)
                {
                    return EagerLoadMany.Cache;
                }

                string innerJoinSelectClause = InnerJoinSelectClause(fromColumn, toTable, throughTable, resolvedForeignKey, model);

                var models = (Repository.Query(innerJoinSelectClause) as IEnumerable <dynamic>).ToList();

                foreach (var m in models)
                {
                    AddReferenceBackToModel(m, model);
                }

                EagerLoadMany.Cache = new DynamicModels(models);

                AddNewAssociationMethod(EagerLoadMany.Cache, model);

                AddRepository(EagerLoadMany.Cache, new DynamicRepository(throughTable));

                return EagerLoadMany.Cache;
            });
        }
Exemplo n.º 3
0
        private DynamicFunctionWithParam InnerJoinFor(dynamic model)
        {
            return((options) =>
            {
                if (EagerLoadMany.ShouldDiscardCache(options))
                {
                    EagerLoadMany.Cache = null;
                }

                if (EagerLoadMany.Cache != null)
                {
                    return EagerLoadMany.Cache;
                }

                var models = (Repository.Query(InnerJoinSelectClause(XRefFromColumn, toTable, throughTable, XRefToColumn, ToTableColumn, PropertyContainingIdValue, model)) as IEnumerable <dynamic>).ToList();

                foreach (var m in models)
                {
                    AddReferenceBackToModel(m, model);
                }

                EagerLoadMany.Cache = new DynamicModels(models);

                AddNewAssociationMethod(EagerLoadMany.Cache, model);

                return EagerLoadMany.Cache;
            });
        }
Exemplo n.º 4
0
        public void Init(dynamic model)
        {
            EagerLoadMany = new EagerLoadMany();

            ForeignKey = ForeignKey ?? ForeignKeyFor(model);

            var toTable = Repository.GetType().Name;

            AddAssociationMethods(model, ForeignKey, toTable);
        }
Exemplo n.º 5
0
        public void Init(dynamic model)
        {
            EagerLoadMany = new EagerLoadMany();

            ForeignKey = ForeignKey ?? SigularId(model);

            PropertyContainingIdValue = PropertyContainingIdValue ?? Id();

            var toTable = Repository.TableName;

            AddAssociationMethods(model, ForeignKey);
        }
Exemplo n.º 6
0
        public void Init(dynamic model)
        {
            EagerLoadMany = new EagerLoadMany();

            ForeignKey = ForeignKey ?? SigularId(model);

            PropertyContainingIdValue = PropertyContainingIdValue ?? Id();

            var toTable = Repository.TableName;

            AddAssociationMethods(model, ForeignKey);
        }
Exemplo n.º 7
0
        public void Init(dynamic model)
        {
            EagerLoadMany = new EagerLoadMany();

            FromColumn = FromColumn ?? ForeignKeyFor(model);

            toTable = Repository.GetType().Name;

            resolvedForeignKey = ForeignKey ?? ForeignKeyFor(Repository);

            AddAssociationMethod(model);

            Model = model;
        }
Exemplo n.º 8
0
        public void Init(dynamic model)
        {
            EagerLoadMany = new EagerLoadMany();

            throughTable = CrossRefenceTable ?? throughTable;

            fromColumn = FromColumn ?? ForeignKeyFor(model);

            toTable = Repository.TableName;

            resolvedForeignKey = ForeignKey ?? ForeignKeyFor(Repository);

            AddAssociationMethods(model);

            Model = model;
        }
Exemplo n.º 9
0
        public void Init(dynamic model)
        {
            EagerLoadMany = new EagerLoadMany();

            toTable = Repository.TableName;

            XRefFromColumn = XRefFromColumn ?? SigularId(model);

            XRefToColumn = XRefToColumn ?? SigularId(Repository);

            ToTableColumn = ToTableColumn ?? Id();

            PropertyContainingIdValue = PropertyContainingIdValue ?? Id();

            AddAssociationMethod(model);

            Model = model;
        }
Exemplo n.º 10
0
        public void Init(dynamic model)
        {
            EagerLoadMany = new EagerLoadMany();

            throughTable = XRefTable ?? throughTable;

            toTable = Repository.TableName;

            XRefFromColumn = XRefFromColumn ?? SigularId(model);

            XRefToColumn = XRefToColumn ?? SigularId(Repository);

            ToTableColumn = ToTableColumn ?? Id();

            PropertyContainingIdValue = PropertyContainingIdValue ?? Id();

            AddAssociationMethods(model);

            Model = model;
        }
Exemplo n.º 11
0
        public IEnumerable <dynamic> EagerLoad(IEnumerable <dynamic> models, dynamic options)
        {
            var sql = InnerJoinSelectClause(XRefFromColumn, toTable, throughTable, XRefToColumn, ToTableColumn, PropertyContainingIdValue, models.ToArray());

            return(EagerLoadMany.Execute(options, Repository, MethodName, sql, models, XRefFromColumn));
        }
Exemplo n.º 12
0
        public void Init(dynamic model)
        {
            EagerLoadMany = new EagerLoadMany();

            FromColumn = FromColumn ?? ForeignKeyFor(model);

            toTable = Repository.GetType().Name;

            resolvedForeignKey = ForeignKey ?? ForeignKeyFor(Repository);

            AddAssociationMethod(model);

            Model = model;
        }
Exemplo n.º 13
0
        public void Init(dynamic model)
        {
            EagerLoadMany = new EagerLoadMany();

            throughTable = CrossRefenceTable ?? throughTable;

            fromColumn = FromColumn ?? ForeignKeyFor(model);

            toTable = Repository.TableName;

            resolvedForeignKey = ForeignKey ?? ForeignKeyFor(Repository);

            AddAssociationMethods(model);

            Model = model;
        }
Exemplo n.º 14
0
        public void Init(dynamic model)
        {
            EagerLoadMany = new EagerLoadMany();

            ForeignKey = ForeignKey ?? ForeignKeyFor(model);

            var toTable = Repository.GetType().Name;

            AddAssociationMethods(model, ForeignKey, toTable);
        }
Exemplo n.º 15
0
        public IEnumerable <dynamic> EagerLoad(IEnumerable <dynamic> models, dynamic options)
        {
            var sql = InnerJoinSelectClause(fromColumn, toTable, throughTable, resolvedForeignKey, models.ToArray());

            return(EagerLoadMany.Execute(options, Repository, Named, sql, models, fromColumn));
        }