Beispiel #1
0
        public MixInValidation(DynamicModel mixWith)
        {
            rules = new List <dynamic>();

            errors = new List <dynamic>();

            @this = mixWith;

            if (HasValidationCapabilities(mixWith))
            {
                mixWith.SetUnTrackedMember("Errors", new DynamicFunction(Errors));

                mixWith.SetUnTrackedMember("IsValid", new DynamicFunctionWithParam(IsValid));

                mixWith.SetUnTrackedMember("FirstError", new DynamicFunction(FirstError));

                IEnumerable <dynamic> validationRules = @this.Validates();

                foreach (var validationRule in validationRules)
                {
                    validationRule.Init(mixWith);

                    AddRule(validationRule);
                }
            }
        }
Beispiel #2
0
        private void AddAssociationMethod(DynamicModel model)
        {
            model.SetUnTrackedMember(
                Named,
                Query(model));

            model.SetUnTrackedMember(
                Singular(Named) + "Ids",
                QueryIds(model));
        }
Beispiel #3
0
        public void Init(DynamicModel model)
        {
            string foreignKeyName = string.IsNullOrEmpty(ForeignKey) ? ForeignKeyFor(model) : ForeignKey;

            model.SetUnTrackedMember(
                Singular(Repository),
                Query(foreignKeyName, Repository.GetType().Name, through.GetType().Name, ForeignKeyFor(Repository), model));
        }
Beispiel #4
0
        public void Init(DynamicModel model)
        {
            string foreignKeyName = string.IsNullOrEmpty(ForeignKey) ? ForeignKeyFor(model) : ForeignKey;

            model.SetUnTrackedMember(
                Singular(Repository),
                new DynamicFunction(() => Repository.SingleWhere(foreignKeyName + " = @0", model.GetMember(Id()))));
        }
Beispiel #5
0
        public void Init(DynamicModel model)
        {
            string foreignKeyName = string.IsNullOrEmpty(ForeignKey) ? ForeignKeyFor(Repository) : ForeignKey;

            string primaryKeyName = string.IsNullOrEmpty(PrimaryKey) ? "Id" : PrimaryKey;

            string whereClause = string.Format("{0} = @0", primaryKeyName);

            model.SetUnTrackedMember(
                Named,
                new DynamicFunction(() => Repository.SingleWhere(whereClause, model.GetMember(foreignKeyName))));
        }
Beispiel #6
0
        public MixInAssociation(DynamicModel mixWith)
        {
            if (!SupportsAssociations(mixWith))
            {
                return;
            }

            IEnumerable <dynamic> associations = (mixWith as dynamic).Associates();

            foreach (dynamic association in associations)
            {
                referencedAssociations.Add(association);
                association.Init(mixWith);
            }

            mixWith.SetUnTrackedMember("AssociationNamed", new DynamicFunctionWithParam(AssociationNamed));
        }
Beispiel #7
0
        public MixInValidation(DynamicModel mixWith)
        {
            rules = new List<dynamic>();

            errors = new List<dynamic>();

            @this = mixWith;

            if (HasValidationCapabilities(mixWith))
            {
                mixWith.SetUnTrackedMember("Errors", new DynamicFunction(Errors));

                mixWith.SetUnTrackedMember("IsValid", new DynamicFunction(IsValid));

                mixWith.SetUnTrackedMember("IsPropertyValid", new DynamicFunctionWithParam(IsValid));

                mixWith.SetUnTrackedMember("FirstError", new DynamicFunction(FirstError));

                IEnumerable<dynamic> validationRules = @this.Validates();

                foreach (var validationRule in validationRules)
                {
                    validationRule.Init(mixWith);

                    AddRule(validationRule);
                }
            }
        }
Beispiel #8
0
        private void AddAssociationMethod(DynamicModel model, string fromColumn, string toTable)
        {
            model.SetUnTrackedMember(
                named,
                Query(fromColumn, toTable, through.GetType().Name, Using ?? ForeignKeyFor(repository), model));

            model.SetUnTrackedMember(
                Singular(named) + "Ids",
                QueryIds(fromColumn, toTable, through.GetType().Name, Using ?? ForeignKeyFor(repository), model));
        }
Beispiel #9
0
        private void AddAssociationMethods(DynamicModel model, string fromColumn, string toTable)
        {
            model.SetUnTrackedMember(named, Query(fromColumn, model));

            model.SetUnTrackedMember(Singular(named) + "Ids", QueryIds(fromColumn, model));
        }
Beispiel #10
0
        private void AddAssociationMethods(DynamicModel model, string fromColumn, string toTable)
        {
            model.SetUnTrackedMember(Named, Query(fromColumn, model));

            model.SetUnTrackedMember(Singular(Named) + "Ids", QueryIds(fromColumn, model));
        }
Beispiel #11
0
        public void Init(DynamicModel model)
        {
            string foreignKeyName = string.IsNullOrEmpty(ForeignKey) ? ForeignKeyFor(Repository) : ForeignKey;

            string primaryKeyName = string.IsNullOrEmpty(PrimaryKey) ? "Id" : PrimaryKey;

            string whereClause = string.Format("{0} = @0", primaryKeyName);

            model.SetUnTrackedMember(
                Named,
                new DynamicFunction(() => Repository.SingleWhere(whereClause, model.GetMember(foreignKeyName))));
        }
Beispiel #12
0
        public MixInAssociation(DynamicModel mixWith)
        {
            if (!SupportsAssociations(mixWith)) return;

            IEnumerable<dynamic> associations = (mixWith as dynamic).Associates();

            foreach (dynamic association in associations)
            {
                referencedAssociations.Add(association);
                association.Init(mixWith);
            }

            mixWith.SetUnTrackedMember("AssociationNamed", new DynamicFunctionWithParam(AssociationNamed));
        }
Beispiel #13
0
        public void Init(DynamicModel model)
        {
            string foreignKeyName = string.IsNullOrEmpty(ForeignKey) ? ForeignKeyFor(model) : ForeignKey;

            model.SetUnTrackedMember(
                Singular(Repository),
                Query(foreignKeyName, Repository.GetType().Name, through.GetType().Name, ForeignKeyFor(Repository), model));
        }
Beispiel #14
0
        public void Init(DynamicModel model)
        {
            string foreignKeyName = string.IsNullOrEmpty(ForeignKey) ? ForeignKeyFor(model) : ForeignKey;

            model.SetUnTrackedMember(
                Singular(Repository),
                new DynamicFunction(() => Repository.SingleWhere(foreignKeyName + " = @0", model.GetMember(Id()))));
        }
Beispiel #15
0
        private void AddAssociationMethod(DynamicModel model)
        {
            model.SetUnTrackedMember(
                Named,
                Query(model));

            model.SetUnTrackedMember(
                Singular(Named) + "Ids",
                QueryIds(model));
        }