diff --git a/SqlSugar/Abstract/DbFirstProvider/DbFirstProvider.cs b/SqlSugar/Abstract/DbFirstProvider/DbFirstProvider.cs index 163bec88a..d65c5df7b 100644 --- a/SqlSugar/Abstract/DbFirstProvider/DbFirstProvider.cs +++ b/SqlSugar/Abstract/DbFirstProvider/DbFirstProvider.cs @@ -13,15 +13,22 @@ namespace SqlSugar private string PropertyDescriptionTemplate { get; set; } private string ConstructorTemplate { get; set; } private string NamespaceTemplate { get; set; } - private string + private List TableInfoList { get; set; } - public DbFirstProvider() { + public DbFirstProvider() + { this.ClassTemplate = DefaultTemplate.ClassTemplate; this.ClassDescriptionTemplate = DefaultTemplate.ClassDescriptionTemplate; this.PropertyTemplate = DefaultTemplate.PropertyTemplate; this.PropertyDescriptionTemplate = DefaultTemplate.PropertyDescriptionTemplate; this.ConstructorTemplate = DefaultTemplate.ConstructorTemplate; this.NamespaceTemplate = DefaultTemplate.NamespaceTemplate; + this.TableInfoList = this.Context.DbMaintenance.GetTableInfoList(); + if (this.Context.DbMaintenance.GetViewInfoList().IsValuable()) + { + this.TableInfoList.AddRange(this.Context.DbMaintenance.GetViewInfoList()); + } + } public List GetSchemaInfoList @@ -79,17 +86,24 @@ namespace SqlSugar #region Where public IDbFirst Where(DbObjectType dbObjectType) { - throw new NotImplementedException(); + if (dbObjectType != DbObjectType.All) + this.TableInfoList = this.TableInfoList.Where(it => it.DbObjectType == dbObjectType).ToList(); + return this; } public IDbFirst Where(Func func) { - throw new NotImplementedException(); + this.TableInfoList=this.TableInfoList.Where(it => func(it.Name)).ToList(); + return this; } public IDbFirst Where(params string[] objectNames) { - throw new NotImplementedException(); + if (objectNames.IsValuable()) + { + this.TableInfoList = this.TableInfoList.Where(it => objectNames.Contains(it.Name)).ToList(); + } + return this; } #endregion diff --git a/SqlSugar/Abstract/DbMaintenanceProvider/DbMaintenanceProvider.cs b/SqlSugar/Abstract/DbMaintenanceProvider/DbMaintenanceProvider.cs index a31699af0..18f548eed 100644 --- a/SqlSugar/Abstract/DbMaintenanceProvider/DbMaintenanceProvider.cs +++ b/SqlSugar/Abstract/DbMaintenanceProvider/DbMaintenanceProvider.cs @@ -19,12 +19,22 @@ namespace SqlSugar public List GetViewInfoList() { string key = "DbMaintenanceProvider.GetViewInfoList"; - return GetListOrCache(key, this.GetViewInfoListSql); + var result= GetListOrCache(key, this.GetViewInfoListSql); + foreach (var item in result) + { + item.DbObjectType = DbObjectType.View; + } + return result; } public List GetTableInfoList() { string key = "DbMaintenanceProvider.GetTableInfoList"; - return GetListOrCache(key, this.GetTableInfoListSql); + var result= GetListOrCache(key, this.GetTableInfoListSql); + foreach (var item in result) + { + item.DbObjectType = DbObjectType.Table; + } + return result; } public virtual List GetColumnInfosByTableName(string tableName) { diff --git a/SqlSugar/Entities/DbTableInfo.cs b/SqlSugar/Entities/DbTableInfo.cs index 55dcab0ee..0dd4c7068 100644 --- a/SqlSugar/Entities/DbTableInfo.cs +++ b/SqlSugar/Entities/DbTableInfo.cs @@ -9,5 +9,6 @@ namespace SqlSugar { public string Name { get; set; } public string Description { get; set; } + public DbObjectType DbObjectType { get; set; } } }