예제 #1
0
        public IEntityLoader <MSSQLTable <TTableContent, TColumnContent> > GetEntityLoader(
            IEntityExtractor <IBaseObject <TTableContent> > entityExtractor = null,
            IEntityPropertyExtractor <ITable <TTableContent, TColumnContent>, TTableContent, IColumn <TColumnContent>, TColumnContent> propertyExtractor         = null,
            IEntityRelationshipExtractor <ITable <TTableContent, TColumnContent>, TTableContent, IColumn <TColumnContent>, TColumnContent> relationshipExtractor = null,
            IEntityHandler <TTableContent, EntityInfo>[] tableContentHandlers = null,
            IEntityHandler <TColumnContent, SimplePropertyEntityInfo>[] propertyContentHandlers = null)
        {
            var tableHandlers  = new List <IEntityHandler <MSSQLTable <TTableContent, TColumnContent>, EntityInfo> >();
            var columnHandlers = new List <IEntityHandler <MSSQLColumn <TTableContent, TColumnContent>, SimplePropertyEntityInfo> >
            {
                new MSSQLColumnHandler <TTableContent, TColumnContent>(),
                new MSSQLColumnDefaultValuetHandler <TTableContent, TColumnContent>()
            };

            if (tableContentHandlers != null && tableContentHandlers.Length != 0)
            {
                tableHandlers.Add(new ContentEntityHandler <MSSQLTable <TTableContent, TColumnContent>, TTableContent, EntityInfo>(tableContentHandlers));
            }

            if (propertyContentHandlers != null && propertyContentHandlers.Length != 0)
            {
                columnHandlers.Add(new ContentEntityHandler <MSSQLColumn <TTableContent, TColumnContent>, TColumnContent, SimplePropertyEntityInfo>(propertyContentHandlers));
            }

            var loader = new EntityLoader <MSSQLTable <TTableContent, TColumnContent>, TTableContent, MSSQLColumn <TTableContent, TColumnContent>, TColumnContent>
                             (entityExtractor, propertyExtractor, relationshipExtractor, tableHandlers, columnHandlers);

            return(loader);
        }
예제 #2
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="T:System.Object" /> class.
        /// </summary>
        public EntityLoader(IEntityExtractor <TTable> entityExtractor = null,
                            IEntityPropertyExtractor <TTable, TTableContent, TColumn, TColumnContent> propertyExtractor         = null,
                            IEntityRelationshipExtractor <TTable, TTableContent, TColumn, TColumnContent> relationshipExtractor = null,
                            IReadOnlyCollection <IEntityHandler <TTable, EntityInfo> > tableHandlers = null,
                            IReadOnlyCollection <IEntityHandler <TColumn, SimplePropertyEntityInfo> > simplePropertiesHandlers = null)
        {
            _entityExtractor       = entityExtractor ?? new EntityExtractor <TTable, TTableContent>();
            _propertyExtractor     = propertyExtractor ?? new EntityPropertyExtractor <ITable <TTableContent, TColumnContent>, TTableContent, IColumn <TColumnContent>, TColumnContent>();
            _relationshipExtractor = relationshipExtractor;

            _tableHandlers            = tableHandlers ?? new IEntityHandler <TTable, EntityInfo> [0];
            _simplePropertiesHandlers = simplePropertiesHandlers ?? new IEntityHandler <TColumn, SimplePropertyEntityInfo> [0];
        }