This commit is contained in:
sunkaixuan
2017-05-29 20:53:46 +08:00
parent 44888d9998
commit a048bf9725
3 changed files with 33 additions and 20 deletions

View File

@@ -17,21 +17,21 @@ namespace OrmTest
{
static void Main(string[] args)
{
/***Unit Test***/
new Field(1).Init();
new Where(1).Init();
new Method(1).Init();
new JoinQuery(1).Init();
new SingleQuery(1).Init();
new SelectQuery(1).Init();
new AutoClose(1).Init();
new Insert(1).Init();
new Delete(1).Init();
new Update(1).Init();
new Mapping(1).Init();
///***Unit Test***/
//new Field(1).Init();
//new Where(1).Init();
//new Method(1).Init();
//new JoinQuery(1).Init();
//new SingleQuery(1).Init();
//new SelectQuery(1).Init();
//new AutoClose(1).Init();
//new Insert(1).Init();
//new Delete(1).Init();
//new Update(1).Init();
//new Mapping(1).Init();
/***Performance Test***/
new SqlSugarPerformance(100).Select();
///***Performance Test***/
//new SqlSugarPerformance(100).Select();
/***Demo***/
OrmTest.Demo.Query.Init();

View File

@@ -147,9 +147,9 @@ namespace SqlSugar
}
classText = classText.Replace(DbFirstTemplate.KeyClassName, className);
classText = classText.Replace(DbFirstTemplate.KeyNamespace, this.Namespace);
classText = classText.Replace(DbFirstTemplate.KeyUsing, IsAttribute ? (this.UsingTemplate + "using " + PubConst.AssemblyName + "\r\t") : this.UsingTemplate);
classText = classText.Replace(DbFirstTemplate.KeyUsing, IsAttribute ? (this.UsingTemplate + "using " + PubConst.AssemblyName + "\r\n") : this.UsingTemplate);
classText = classText.Replace(DbFirstTemplate.KeyClassDescription, DbFirstTemplate.ClassDescriptionTemplate.Replace(DbFirstTemplate.KeyClassDescription, tableInfo.Description + "\r\n"));
classText = classText.Replace(DbFirstTemplate.KeySugarTable, IsAttribute ? string.Format(DbFirstTemplate.ValueSugarTable, tableInfo.Name) : null);
classText = classText.Replace(DbFirstTemplate.KeySugarTable, IsAttribute ? string.Format(DbFirstTemplate.ValueSugarTable, tableInfo.Name): null);
if (columns.IsValuable())
{
foreach (var item in columns)
@@ -218,16 +218,29 @@ namespace SqlSugar
private string GetPropertyText(DbColumnInfo item, string PropertyText)
{
string SugarColumnText = DbFirstTemplate.ValueSugarCoulmn;
var hasSugarColumn = item.IsPrimarykey == true || item.IsIdentity == true || item.DbColumnName.IsValuable();
var propertyName = GetPropertyName(item);
var isMappingColumn = propertyName != item.DbColumnName;
var hasSugarColumn = item.IsPrimarykey == true || item.IsIdentity == true || isMappingColumn;
if (hasSugarColumn && this.IsAttribute)
{
List<string> joinList = new List<string>();
if (item.IsPrimarykey) {
joinList.Add("IsPrimarykey=true");
}
if (item.IsIdentity)
{
joinList.Add("IsIdentity=true");
}
if (isMappingColumn) {
joinList.Add("ColumnName=\""+item.DbColumnName+"\"");
}
SugarColumnText = string.Format(SugarColumnText,string.Join(",",joinList));
}
else
{
SugarColumnText = null;
}
string typeString = GetPropertyTypeName(item);
var propertyName = GetPropertyName(item);
PropertyText = PropertyText.Replace(DbFirstTemplate.KeySugarColumn, SugarColumnText);
PropertyText = PropertyText.Replace(DbFirstTemplate.KeyPropertyType, typeString);
PropertyText = PropertyText.Replace(DbFirstTemplate.KeyPropertyName, propertyName);

View File

@@ -58,8 +58,8 @@ namespace SqlSugar
#endregion
#region Replace Value
public const string ValueSugarTable = "[SugarTable(\"{0}\")]";
public const string ValueSugarCoulmn = "[SugarColumn({0})]";
public const string ValueSugarTable = "\r\n"+ClassSpace+"[SugarTable(\"{0}\")]";
public const string ValueSugarCoulmn = "\r\n"+PropertySpace+"[SugarColumn({0})]";
#endregion
#region Space