Browse Source

-

pull/12/MERGE
sunkaixuan 8 years ago
parent
commit
fb1dd1aec5
  1. 24
      SqlSugar/Abstract/DbFirstProvider/DbFirstProvider.cs
  2. 14
      SqlSugar/Abstract/DbMaintenanceProvider/DbMaintenanceProvider.cs
  3. 1
      SqlSugar/Entities/DbTableInfo.cs

24
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<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

14
SqlSugar/Abstract/DbMaintenanceProvider/DbMaintenanceProvider.cs

@ -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)
{

1
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; }
}
}

Loading…
Cancel
Save