Пример #1
0
        public EntityDescriptor(DbModuleOptions dbOptions, Type entityType, ISqlAdapter sqlAdapter)
        {
            DbOptions = dbOptions;

            ModuleName = dbOptions.Name;

            SqlAdapter = sqlAdapter;

            EntityType = entityType;

            Database = sqlAdapter.Database;

            PrimaryKey = new PrimaryKeyDescriptor();

            SoftDelete = EntityType.IsSubclassOfGeneric(typeof(EntityWithSoftDelete <,>));

            SetTableName();

            SetIgnore();

            SetColumns();

            var sqlBuilder = new EntitySqlBuilder(this);

            Sql = sqlBuilder.Build();

            IsEntityBase = EntityType.IsSubclassOfGeneric(typeof(EntityBase <>)) || EntityType.IsSubclassOfGeneric(typeof(EntityBaseWithSoftDelete <,>));
        }
Пример #2
0
        public EntityDescriptor(IDbContext dbContext, Type entityType)
        {
            DbContext = dbContext;

            DbOptions = dbContext.Options.DbModuleOptions;

            SqlAdapter = dbContext.Options.SqlAdapter;

            ModuleName = DbOptions.Name;

            EntityType = entityType;

            Database = SqlAdapter.Database;

            PrimaryKey = new PrimaryKeyDescriptor();

            SoftDelete = EntityType.IsSubclassOfGeneric(typeof(EntityWithSoftDelete <,>));

            SetTableName();

            SetIgnore();

            SetColumns();

            var sqlBuilder = new EntitySqlBuilder(this, dbContext.Options.DbOptions);

            Sql = sqlBuilder.Build();

            IsEntityBase = EntityType.IsSubclassOfGeneric(typeof(EntityBase <>)) || EntityType.IsSubclassOfGeneric(typeof(EntityBaseWithSoftDelete <,>));

            IsTenant = typeof(ITenant).IsAssignableFrom(EntityType);
        }
Пример #3
0
        public EntityDescriptor(DbOptions dbOptions, DbModuleOptions dbModuleOptions, Type entityType, ISqlAdapter sqlAdapter)
        {
            DbOptions = dbOptions;

            ModuleOptions = dbModuleOptions;

            ModuleName = dbModuleOptions.Name;

            SqlAdapter = sqlAdapter;

            EntityType = entityType;

            Database = sqlAdapter.Database;

            PrimaryKey = new PrimaryKeyDescriptor();

            //实体基类
            IsEntityBase = EntityType.GetInterfaces().Any(m => m == typeof(IBase));

            //软删除
            IsSoftDelete = EntityType.GetInterfaces().Any(m => m == typeof(ISoftDelete));

            SetTableName();

            SetIgnore();

            SetColumns();

            var sqlBuilder = new EntitySqlBuilder(this);

            Sql = sqlBuilder.Build();
        }