Exemplo n.º 1
0
        public static ICompareFluentInterface FromMemento(EngineMemento memento)
        {
            if (memento == null)
            {
                throw new ArgumentNullException(nameof(memento));
            }


            var validationResults = new List <ValidationResult>();

            if (!Validator.TryValidateObject(memento, new ValidationContext(memento), validationResults))
            {
                throw new ExtendedValidationException("memento", memento, validationResults);
            }


            var f = new FluentInterface();

            if (memento.Entities == null)
            {
                return(f);
            }
            if (memento.Entities.Count == 0)
            {
                return(f);
            }

            foreach (var entityMemento in memento.Entities)
            {
                IKeyProvider <Entity> keyProvider;
                if (entityMemento.KeyUseGuid)
                {
                    keyProvider = AsKey.UseGuid;
                }
                else
                {
                    keyProvider = AsKey.UseAttributes(entityMemento.KeyAttributeNames.ToArray());
                }

                if (entityMemento.AttributesToSkip?.Count > 0)
                {
                    var skipAttributeCriteria = Skip.Attributes(entityMemento.AttributesToSkip.ToArray());
                    f.Entity(entityMemento.EntityName, keyProvider, skipAttributeCriteria, entityMemento.OnlyActive);
                }
                else
                {
                    f.Entity(entityMemento.EntityName, keyProvider, entityMemento.OnlyActive);
                }
            }

            return(f);
        }
Exemplo n.º 2
0
        public static ICompareFluentInterface Entity(string entityName, IKeyProvider <Entity> keyProvider, Action <QueryExpression> filterCriteria)
        {
            var f = new FluentInterface();

            return(f.Entity(entityName, keyProvider, filterCriteria));
        }
Exemplo n.º 3
0
        public static ICompareFluentInterface Entity(string entityName, IKeyProvider <Entity> keyProvider, ISkipAttributeCriteria skipAttributeCriteria, bool onlyActiveRecords)
        {
            var f = new FluentInterface();

            return(f.Entity(entityName, keyProvider, skipAttributeCriteria, onlyActiveRecords));
        }
Exemplo n.º 4
0
        public static ICompareFluentInterface Entity(string entityName, IKeyProvider <Entity> keyProvider)
        {
            var f = new FluentInterface();

            return(f.Entity(entityName, keyProvider));
        }