|
|
@ -26,7 +26,7 @@ namespace SqlSugar |
|
|
|
} |
|
|
|
public class MyContractResolver : Newtonsoft.Json.Serialization.DefaultContractResolver |
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public MyContractResolver() |
|
|
|
{ |
|
|
@ -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) |
|
|
|
{ |
|
|
|
return base.CreateProperties(type, memberSerialization); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
if (UtilMethods.GetUnderType(item.PropertyType) == UtilConstants.DateType) |
|
|
|
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) |
|
|
|
{ |
|
|
|
CreateDateProperty(type, item); |
|
|
|
if (UtilMethods.GetUnderType(item.PropertyType) == UtilConstants.DateType) |
|
|
|
{ |
|
|
|
CreateDateProperty(type, item); |
|
|
|
} |
|
|
|
} |
|
|
|
return list; |
|
|
|
} |
|
|
|
return list; |
|
|
|
} |
|
|
|
|
|
|
|
private static void CreateDateProperty(Type type, JsonProperty item) |
|
|
@ -66,5 +73,5 @@ namespace SqlSugar |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|