Example #1
0
        /// <summary>
        /// Does a cascade delete of an object for this property
        /// </summary>
        /// <param name="Object">Object</param>
        /// <param name="Source">Source info</param>
        /// <param name="ObjectsSeen">Objects seen thus far</param>
        /// <returns>Batch object with the appropriate commands</returns>
        public override IBatch CascadeDelete(ClassType Object, ISourceInfo Source, IList <object> ObjectsSeen)
        {
            QueryProvider.Manager Provider        = IoC.Manager.Bootstrapper.Resolve <QueryProvider.Manager>();
            Mapper.Manager        MappingProvider = IoC.Manager.Bootstrapper.Resolve <Mapper.Manager>();
            IMapping PropertyMapping = MappingProvider[typeof(DataType), Source];
            IBatch   Batch           = Provider.Batch(Source);
            var      AspectObject    = Object as IORMObject;

            if (Object == null || (AspectObject != null && ObjectsSeen.Contains(Mapping.IDProperties.FirstOrDefault().GetValue(Object))))
            {
                return(Batch);
            }
            if (AspectObject != null)
            {
                ObjectsSeen.Add(Mapping.IDProperties.FirstOrDefault().GetValue(Object));
            }
            IEnumerable <DataType> IList = CompiledExpression(Object);

            if (IList == null)
            {
                return(Batch);
            }
            foreach (DataType Item in IList.Where(x => x != null))
            {
                foreach (IProperty <DataType> Property in PropertyMapping.Properties.Where(x => x.Cascade))
                {
                    Batch.AddCommand(Property.CascadeDelete(Item, Source, ObjectsSeen.ToList()));
                }
                Batch.AddCommand(Provider.Generate <DataType>(Source, PropertyMapping, Structure).Delete(Item));
            }
            Utilities.IoC.Manager.Bootstrapper.Resolve <DataTypes.Caching.Manager>().Cache().RemoveByTag(typeof(DataType).GetName());
            return(Batch);
        }
Example #2
0
        /// <summary>
        /// Called to create a batch that saves items from the joining tables
        /// </summary>
        /// <param name="Object">Object</param>
        /// <param name="Source">Source info</param>
        /// <param name="ObjectsSeen">Objects seen thus far</param>
        /// <returns>Batch object with the appropriate commands</returns>
        public override IBatch CascadeJoinsSave(ClassType Object, ISourceInfo Source, IList <object> ObjectsSeen)
        {
            QueryProvider.Manager Provider        = IoC.Manager.Bootstrapper.Resolve <QueryProvider.Manager>();
            Mapper.Manager        MappingProvider = IoC.Manager.Bootstrapper.Resolve <Mapper.Manager>();
            IMapping PropertyMapping = MappingProvider[typeof(DataType), Source];
            IBatch   Batch           = Provider.Batch(Source);
            var      AspectObject    = Object as IORMObject;

            if (Object == null || (AspectObject != null && ObjectsSeen.Contains(Mapping.IDProperties.FirstOrDefault().GetValue(Object))))
            {
                return(Batch);
            }
            if (AspectObject != null)
            {
                ObjectsSeen.Add(Mapping.IDProperties.FirstOrDefault().GetValue(Object));
            }
            IEnumerable <DataType> IList = CompiledExpression(Object);

            if (IList == null)
            {
                return(Batch);
            }
            foreach (DataType Item in IList.Where(x => x != null))
            {
                foreach (IProperty <DataType> Property in PropertyMapping.Properties)
                {
                    if (!Property.Cascade &&
                        (Property is IMultiMapping ||
                         Property is ISingleMapping))
                    {
                        Batch.AddCommand(Property.JoinsSave(Item, Source, ObjectsSeen.ToList()));
                    }
                    else if (Property.Cascade)
                    {
                        Batch.AddCommand(Property.CascadeJoinsSave(Item, Source, ObjectsSeen.ToList()));
                    }
                }
            }
            Batch.AddCommand(Provider.Generate <ClassType>(Source, Mapping, Structure).JoinsSave <ICollection <DataType>, DataType>(this, Object));
            return(Batch);
        }
Example #3
0
        /// <summary>
        /// Called to create a batch that deletes items from the joining tables
        /// </summary>
        /// <param name="Object">Object</param>
        /// <param name="Source">Source info</param>
        /// <param name="ObjectsSeen">Objects seen thus far</param>
        /// <returns>Batch object with the appropriate commands</returns>
        public override IBatch CascadeJoinsDelete(ClassType Object, ISourceInfo Source, IList <object> ObjectsSeen)
        {
            QueryProvider.Manager Provider        = IoC.Manager.Bootstrapper.Resolve <QueryProvider.Manager>();
            Mapper.Manager        MappingProvider = IoC.Manager.Bootstrapper.Resolve <Mapper.Manager>();
            IMapping PropertyMapping = MappingProvider[typeof(DataType), Source];
            IBatch   Batch           = Provider.Batch(Source);
            var      AspectObject    = Object as IORMObject;

            if (Object == null || (AspectObject != null && ObjectsSeen.Contains(Mapping.IDProperties.FirstOrDefault().GetValue(Object))))
            {
                return(Provider.Batch(Source));
            }
            if (AspectObject != null)
            {
                ObjectsSeen.Add(Mapping.IDProperties.FirstOrDefault().GetValue(Object));
            }
            DataType Item = CompiledExpression(Object);

            if (Item == null)
            {
                return(Batch);
            }
            foreach (IProperty <DataType> Property in PropertyMapping.Properties)
            {
                if (!Property.Cascade &&
                    (Property is ISingleMapping ||
                     Property is IMultiMapping))
                {
                    Batch.AddCommand(Property.JoinsDelete(Item, Source, ObjectsSeen.ToList()));
                }
                else if (Property.Cascade)
                {
                    Batch.AddCommand(Property.CascadeJoinsDelete(Item, Source, ObjectsSeen.ToList()));
                }
            }
            return(Batch);
        }
Example #4
0
 /// <summary>
 /// Sets up the property
 /// </summary>
 /// <param name="MappingProvider">Mapping provider</param>
 /// <param name="QueryProvider">Query provider</param>
 /// <param name="Source">Source info</param>
 public override void Setup(ISourceInfo Source, Mapper.Manager MappingProvider, QueryProvider.Manager QueryProvider)
 {
     ForeignMapping = MappingProvider[Type, Source];
     Structure      = MappingProvider.GetStructure(Mapping.DatabaseConfigType);
     QueryProvider.Generate <ClassType>(Source, Mapping, Structure).SetupLoadCommands(this);
 }
 /// <summary>
 /// Sets up the property
 /// </summary>
 /// <param name="MappingProvider">Mapping provider</param>
 /// <param name="QueryProvider">Query provider</param>
 /// <param name="Source">Source info</param>
 public override void Setup(ISourceInfo Source, Mapper.Manager MappingProvider, QueryProvider.Manager QueryProvider)
 {
     Structure = MappingProvider.GetStructure(Mapping.DatabaseConfigType);
 }
 /// <summary>
 /// Sets up the property
 /// </summary>
 /// <param name="MappingProvider">Mapping provider</param>
 /// <param name="QueryProvider">Query provider</param>
 /// <param name="Source">Source info</param>
 public override void Setup(ISourceInfo Source, Mapper.Manager MappingProvider, QueryProvider.Manager QueryProvider)
 {
     ForeignMapping = MappingProvider[Type, Source];
     QueryProvider.Generate <ClassType>(Source, Mapping).SetupLoadCommands(this);
 }
Example #7
0
 /// <summary>
 /// Sets up the property
 /// </summary>
 /// <param name="MappingProvider">Mapping provider</param>
 /// <param name="QueryProvider">Query provider</param>
 /// <param name="Source">Source info</param>
 public override void Setup(ISourceInfo Source, Mapper.Manager MappingProvider, QueryProvider.Manager QueryProvider)
 {
 }
Example #8
0
 /// <summary>
 /// Sets up the property, is used internally
 /// </summary>
 /// <param name="MappingProvider">Mapping provider</param>
 /// <param name="QueryProvider">Query provider</param>
 /// <param name="Source">Source info</param>
 public abstract void Setup(ISourceInfo Source, Mapper.Manager MappingProvider, QueryProvider.Manager QueryProvider);