This commit is contained in:
sunkaixuan
2017-05-29 15:37:38 +08:00
parent 5bbe4c1b2a
commit c7ff651b5b
4 changed files with 22 additions and 10 deletions

View File

@@ -164,7 +164,7 @@ namespace SqlSugar
List<string> dateThrow = bind.DateThrow;
List<string> shortThrow = bind.ShortThrow;
MethodInfo method = null;
var transformedPropertyName = bind.ChangeDBTypeToCSharpType(dbTypeName);
var transformedPropertyName = bind.GetCSharpType(dbTypeName);
var objTypeName = bindType.Name.ToLower();
var isEnum = bindType.IsEnum;
if (isEnum)

View File

@@ -158,7 +158,6 @@ namespace SqlSugar
string PropertyDescriptionText = DbFirstTemplate.PropertyDescriptionTemplate;
string propertyName=GetPropertyName(item);
string propertyTypeName = GetPropertyTypeName(item);
string proertypeDefaultValue = GetProertypeDefaultValue(item);
PropertyText = GetPropertyText(item, PropertyText);
PropertyDescriptionText = GetPropertyDescriptionText(item, PropertyDescriptionText);
PropertyText = PropertyDescriptionText + PropertyText;
@@ -167,11 +166,12 @@ namespace SqlSugar
{
ConstructorText = ConstructorText.Replace(DbFirstTemplate.KeyPropertyName, propertyName);
ConstructorText = ConstructorText.Replace(DbFirstTemplate.KeyPropertyType, propertyTypeName);
ConstructorText = ConstructorText.Replace(DbFirstTemplate.KeyDefaultValue, proertypeDefaultValue)+(isLast?"":"\r\n"+DbFirstTemplate.KeyPropertyName);
ConstructorText = ConstructorText.Replace(DbFirstTemplate.KeyDefaultValue, GetPropertyTypeConvert(item)) +(isLast?"":"\r\n"+DbFirstTemplate.KeyPropertyName);
}
}
}
classText = classText.Replace(DbFirstTemplate.KeyConstructor, ConstructorText);
classText = classText.Replace(DbFirstTemplate.KeyPropertyName, null);
result.Add(className, classText);
}
}
@@ -232,13 +232,18 @@ namespace SqlSugar
private string GetPropertyTypeName(DbColumnInfo item)
{
string typeString = this.Context.Ado.DbBind.ChangeDBTypeToCSharpType(item.DataType);
if (typeString != "string" && item.IsNullable)
string result = this.Context.Ado.DbBind.GetCSharpType(item.DataType);
if (result != "string" && item.IsNullable)
{
typeString += "?";
result += "?";
}
return typeString;
return result;
}
private string GetPropertyTypeConvert(DbColumnInfo item)
{
string result = "(\""+GetProertypeDefaultValue(item) +"\")";
return result;
}
private string GetPropertyDescriptionText(DbColumnInfo item, string propertyDescriptionText)

View File

@@ -35,7 +35,7 @@ namespace SqlSugar
PropertySpace + "/// Nullable:{IsNullable}\r\n" +
PropertySpace + "/// </summary>";
public static string ConstructorTemplate = PropertySpace + "this.{PropertyName} =Convert.To{PropertyType}(\"{DefaultValue}\");\r\n";
public static string ConstructorTemplate = PropertySpace + "this.{PropertyName} ={PropertyType}(\"{DefaultValue}\");\r\n";
public static string UsingTemplate = "using System;\r\n" +
"using System.Linq;\r\n" +

View File

@@ -1,8 +1,10 @@
namespace SqlSugar
using System;
namespace SqlSugar
{
public class MySqlDbBind : DbBindProvider
{
public override string ChangeDBTypeToCSharpType(string typeName)
public override string GetCSharpType(string typeName)
{
string reval;
switch (typeName.ToLower())
@@ -91,5 +93,10 @@
}
return reval;
}
public override string GetCSharpConvert(string dbTypeName)
{
throw new NotImplementedException();
}
}
}