Пример #1
0
        private void OnLoadingType(MigratorLoadingTypeFromOleDBEventArgs loadingEventArgs)
        {
            if (LoadingTypeFromOleDb == null)
            {
                return;
            }

            LoadingTypeFromOleDb(this, loadingEventArgs);
        }
Пример #2
0
        private void LoadEntityType(Type entityType, IObjectContainer container)
        {
            var tableAttrib = entityType.GetAttribute <TableInformationAttribute>();

            if (tableAttrib == null)
            {
                return;
            }

            var properties = entityType.GetProperties(BindingFlags.Public | BindingFlags.Instance)
                             .Where(prop => prop.GetAttribute <ColumnInformationAttribute>() != null)
                             .ToList();

            if (properties.Count == 0)
            {
                return;
            }

            var columnList = properties.Select(
                prop => prop.GetAttribute <ColumnInformationAttribute>().ColumnName).ToArray();

            var select = GetSelectProvider().GetSqlQuery(tableAttrib.TableName, columnList, TopRowsPerTable);

            var loadingEventArgs = new MigratorLoadingTypeFromOleDBEventArgs
            {
                EntityType     = entityType,
                SqlSelectQuery = select, EntityPropertiesToLoad = properties
            };

            OnLoadingType(loadingEventArgs);

            if (loadingEventArgs.Cancel)
            {
                return;
            }

            var itemsCount = AddOledbRowsToEntity(loadingEventArgs.EntityType, loadingEventArgs.SqlSelectQuery, loadingEventArgs.EntityPropertiesToLoad
                                                  , container);

            OnLoadedType(new MigratorLoadedTypeFromOleDBEventArgs
            {
                EntityType      = entityType,
                LoadedRowsCount = itemsCount
            });
        }