mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-05-04 04:37:58 +08:00
Update dynamic class
This commit is contained in:
parent
f56795bd55
commit
39a70306d9
@ -18,12 +18,19 @@ namespace SqlSugar
|
|||||||
return new DynamicProperyBuilder();
|
return new DynamicProperyBuilder();
|
||||||
}
|
}
|
||||||
public DynamicBuilder baseBuilder;
|
public DynamicBuilder baseBuilder;
|
||||||
public DynamicProperyBuilder CreateProperty(string propertyName, Type properyType, SugarColumn table)
|
public DynamicProperyBuilder CreateProperty(string propertyName, Type properyType, SugarColumn column=null)
|
||||||
{
|
{
|
||||||
|
if (column == null)
|
||||||
|
{
|
||||||
|
column = new SugarColumn()
|
||||||
|
{
|
||||||
|
ColumnName=propertyName
|
||||||
|
};
|
||||||
|
}
|
||||||
PropertyMetadata addItem = new PropertyMetadata();
|
PropertyMetadata addItem = new PropertyMetadata();
|
||||||
addItem.Name = propertyName;
|
addItem.Name = propertyName;
|
||||||
addItem.Type = properyType;
|
addItem.Type = properyType;
|
||||||
addItem.CustomAttributes = new List<CustomAttributeBuilder>() { baseBuilder.GetProperty(table) };
|
addItem.CustomAttributes = new List<CustomAttributeBuilder>() { baseBuilder.GetProperty(column) };
|
||||||
baseBuilder.propertyAttr.Add(addItem);
|
baseBuilder.propertyAttr.Add(addItem);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -23,11 +23,15 @@ namespace SqlSugar
|
|||||||
this.context = context;
|
this.context = context;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DynamicProperyBuilder CreateClass(string entityName, SugarTable table, Type baseType = null, Type[] interfaces = null)
|
public DynamicProperyBuilder CreateClass(string entityName, SugarTable table=null, Type baseType = null, Type[] interfaces = null)
|
||||||
{
|
{
|
||||||
this.baseType = baseType;
|
this.baseType = baseType;
|
||||||
this.interfaces = interfaces;
|
this.interfaces = interfaces;
|
||||||
this.entityName = entityName;
|
this.entityName = entityName;
|
||||||
|
if (table == null)
|
||||||
|
{
|
||||||
|
table = new SugarTable() { TableName = entityName };
|
||||||
|
}
|
||||||
this.entityAttr = new List<CustomAttributeBuilder>() { GetEntity(table) };
|
this.entityAttr = new List<CustomAttributeBuilder>() { GetEntity(table) };
|
||||||
return new DynamicProperyBuilder() { baseBuilder=this};
|
return new DynamicProperyBuilder() { baseBuilder=this};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user