This commit is contained in:
sunkaixuan
2017-05-29 00:55:48 +08:00
parent cca1d61fe0
commit fb1dd1aec5
3 changed files with 32 additions and 7 deletions

View File

@@ -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<DbTableInfo> 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<SchemaInfo> 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<string, bool> 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

View File

@@ -19,12 +19,22 @@ namespace SqlSugar
public List<DbTableInfo> GetViewInfoList()
{
string key = "DbMaintenanceProvider.GetViewInfoList";
return GetListOrCache<DbTableInfo>(key, this.GetViewInfoListSql);
var result= GetListOrCache<DbTableInfo>(key, this.GetViewInfoListSql);
foreach (var item in result)
{
item.DbObjectType = DbObjectType.View;
}
return result;
}
public List<DbTableInfo> GetTableInfoList()
{
string key = "DbMaintenanceProvider.GetTableInfoList";
return GetListOrCache<DbTableInfo>(key, this.GetTableInfoListSql);
var result= GetListOrCache<DbTableInfo>(key, this.GetTableInfoListSql);
foreach (var item in result)
{
item.DbObjectType = DbObjectType.Table;
}
return result;
}
public virtual List<DbColumnInfo> GetColumnInfosByTableName(string tableName)
{

View File

@@ -9,5 +9,6 @@ namespace SqlSugar
{
public string Name { get; set; }
public string Description { get; set; }
public DbObjectType DbObjectType { get; set; }
}
}