mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-08-23 22:11:36 +08:00
Support Json
This commit is contained in:
parent
f1030ab8aa
commit
57d087f413
@ -8,7 +8,7 @@ namespace OrmTest
|
|||||||
{
|
{
|
||||||
static void Main(string[] args)
|
static void Main(string[] args)
|
||||||
{
|
{
|
||||||
//OldTestMain.Init();
|
OldTestMain.Init();
|
||||||
|
|
||||||
//Demo
|
//Demo
|
||||||
Demo1_SqlSugarClient.Init();
|
Demo1_SqlSugarClient.Init();
|
||||||
|
@ -113,7 +113,10 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
if (columnInfo.PropertyInfo.PropertyType.IsClass() && columnInfo.PropertyInfo.PropertyType != UtilConstants.ByteArrayType && columnInfo.PropertyInfo.PropertyType != UtilConstants.ObjType)
|
if (columnInfo.PropertyInfo.PropertyType.IsClass() && columnInfo.PropertyInfo.PropertyType != UtilConstants.ByteArrayType && columnInfo.PropertyInfo.PropertyType != UtilConstants.ObjType)
|
||||||
{
|
{
|
||||||
BindClass(generator, result, columnInfo.PropertyInfo);
|
if (this.ReaderKeys.Any(it => it.Equals(fileName, StringComparison.CurrentCultureIgnoreCase)))
|
||||||
|
{
|
||||||
|
BindClass(generator, result, columnInfo,ReaderKeys.First(it => it.Equals(fileName, StringComparison.CurrentCultureIgnoreCase)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -133,14 +136,24 @@ namespace SqlSugar
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Private methods
|
#region Private methods
|
||||||
private bool IsIgnore(Type type, PropertyInfo propertyInfo)
|
private void BindClass(ILGenerator generator, LocalBuilder result, EntityColumnInfo columnInfo, string fieldName)
|
||||||
{
|
{
|
||||||
return Context.IgnoreColumns != null && Context.IgnoreColumns.Any(it => it.PropertyName.Equals(propertyInfo.Name, StringComparison.CurrentCultureIgnoreCase)
|
if (columnInfo.IsJson)
|
||||||
&& it.EntityName.Equals(type.Name, StringComparison.CurrentCultureIgnoreCase));
|
{
|
||||||
}
|
MethodInfo method = null;
|
||||||
private void BindClass(ILGenerator generator, LocalBuilder result, PropertyInfo propertyInfo)
|
int i = DataRecord.GetOrdinal(fieldName);
|
||||||
{
|
Label endIfLabel = generator.DefineLabel();
|
||||||
|
generator.Emit(OpCodes.Ldarg_0);
|
||||||
|
generator.Emit(OpCodes.Ldc_I4, i);
|
||||||
|
generator.Emit(OpCodes.Callvirt, isDBNullMethod);
|
||||||
|
generator.Emit(OpCodes.Brtrue, endIfLabel);
|
||||||
|
generator.Emit(OpCodes.Ldloc, result);
|
||||||
|
generator.Emit(OpCodes.Ldarg_0);
|
||||||
|
generator.Emit(OpCodes.Ldc_I4, i);
|
||||||
|
generator.Emit(OpCodes.Call, method);
|
||||||
|
generator.Emit(OpCodes.Callvirt, columnInfo.PropertyInfo.GetSetMethod());
|
||||||
|
generator.MarkLabel(endIfLabel);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
private void BindField(ILGenerator generator, LocalBuilder result, EntityColumnInfo columnInfo, string fieldName)
|
private void BindField(ILGenerator generator, LocalBuilder result, EntityColumnInfo columnInfo, string fieldName)
|
||||||
{
|
{
|
||||||
|
@ -169,6 +169,7 @@ namespace SqlSugar
|
|||||||
column.IsEnableUpdateVersionValidation = sugarColumn.IsEnableUpdateVersionValidation;
|
column.IsEnableUpdateVersionValidation = sugarColumn.IsEnableUpdateVersionValidation;
|
||||||
column.IsTranscoding = sugarColumn.IsTranscoding;
|
column.IsTranscoding = sugarColumn.IsTranscoding;
|
||||||
column.SerializeDateTimeFormat = sugarColumn.SerializeDateTimeFormat;
|
column.SerializeDateTimeFormat = sugarColumn.SerializeDateTimeFormat;
|
||||||
|
column.IsJson = sugarColumn.IsJson;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -29,5 +29,6 @@ namespace SqlSugar
|
|||||||
public bool IsOnlyIgnoreInsert { get; set; }
|
public bool IsOnlyIgnoreInsert { get; set; }
|
||||||
public bool IsTranscoding { get; set; }
|
public bool IsTranscoding { get; set; }
|
||||||
public string SerializeDateTimeFormat { get; set; }
|
public string SerializeDateTimeFormat { get; set; }
|
||||||
|
public bool IsJson { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -141,6 +141,13 @@ namespace SqlSugar
|
|||||||
get { return _SerializeDateTimeFormat; }
|
get { return _SerializeDateTimeFormat; }
|
||||||
set { _SerializeDateTimeFormat = value; }
|
set { _SerializeDateTimeFormat = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool _IsJson;
|
||||||
|
public bool IsJson
|
||||||
|
{
|
||||||
|
get { return _IsJson; }
|
||||||
|
set { _IsJson = value; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user