mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-09-18 17:48:11 +08:00
performance optimization
This commit is contained in:
@@ -16,7 +16,7 @@ namespace OrmTest.Models
|
||||
public int? SchoolId { get; set; }
|
||||
public string Name { get; set; }
|
||||
public DateTime? CreateTime { get; set; }
|
||||
[SugarColumn(IsIgnore=true)]
|
||||
[SugarColumn(IsIgnore=true,NoSerialize =true)]
|
||||
public int TestId { get; set; }
|
||||
}
|
||||
|
||||
|
@@ -35,24 +35,31 @@ namespace SqlSugar
|
||||
|
||||
protected override IList<JsonProperty> CreateProperties(Type type, MemberSerialization memberSerialization)
|
||||
{
|
||||
var list = type.GetProperties()
|
||||
.Where(x => !x.GetCustomAttributes(true).Any(a => (a is SugarColumn) && ((SugarColumn)a).NoSerialize == true))
|
||||
.Select(p => new JsonProperty()
|
||||
{
|
||||
PropertyName = p.Name,
|
||||
PropertyType = p.PropertyType,
|
||||
Readable = true,
|
||||
Writable = true,
|
||||
ValueProvider = base.CreateMemberValueProvider(p)
|
||||
}).ToList();
|
||||
foreach (var item in list)
|
||||
if (type.IsAnonymousType()||type==UtilConstants.ObjType|| type.Namespace=="SqlSugar"|| type.IsClass()==false)
|
||||
{
|
||||
if (UtilMethods.GetUnderType(item.PropertyType) == UtilConstants.DateType)
|
||||
{
|
||||
CreateDateProperty(type, item);
|
||||
}
|
||||
return base.CreateProperties(type, memberSerialization);
|
||||
}
|
||||
else
|
||||
{
|
||||
var list = type.GetProperties()
|
||||
.Where(x => !x.GetCustomAttributes(true).Any(a => (a is SugarColumn) && ((SugarColumn)a).NoSerialize == true))
|
||||
.Select(p => new JsonProperty()
|
||||
{
|
||||
PropertyName = p.Name,
|
||||
PropertyType = p.PropertyType,
|
||||
Readable = true,
|
||||
Writable = true,
|
||||
ValueProvider = base.CreateMemberValueProvider(p)
|
||||
}).ToList();
|
||||
foreach (var item in list)
|
||||
{
|
||||
if (UtilMethods.GetUnderType(item.PropertyType) == UtilConstants.DateType)
|
||||
{
|
||||
CreateDateProperty(type, item);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
private static void CreateDateProperty(Type type, JsonProperty item)
|
||||
|
Reference in New Issue
Block a user