mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-08-23 13:06:50 +08:00
Support Json
This commit is contained in:
parent
bcd187ec58
commit
1d3bfdadfd
@ -19,6 +19,7 @@ namespace OrmTest
|
|||||||
OnLogExecuting = (sql, p) =>
|
OnLogExecuting = (sql, p) =>
|
||||||
{
|
{
|
||||||
Console.WriteLine(sql);
|
Console.WriteLine(sql);
|
||||||
|
Console.WriteLine(string.Join(",", p?.Select(it => it.ParameterName + ":" + it.Value)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -12,10 +12,10 @@ namespace OrmTest
|
|||||||
public static void Json()
|
public static void Json()
|
||||||
{
|
{
|
||||||
Db.CodeFirst.InitTables<JsonTest>();
|
Db.CodeFirst.InitTables<JsonTest>();
|
||||||
Db.DbMaintenance.TruncateTable("JsonTest");
|
Db.DbMaintenance.TruncateTable<JsonTest>();
|
||||||
Db.Insertable(new JsonTest() { Order = new Order { Id = 1, Name = "order1" } }).ExecuteCommand();
|
Db.Insertable(new JsonTest() { Order = new Order { Id = 1, Name = "order1" } }).ExecuteCommand();
|
||||||
var list = Db.Queryable<JsonTest>().ToList();
|
var list = Db.Queryable<JsonTest>().ToList();
|
||||||
Db.Updateable(new JsonTest() { Id=1,Order = new Order { Id = 2, Name = "order2" } }).ExecuteCommand();
|
Db.Updateable(new JsonTest() { Id = 1, Order = new Order { Id = 2, Name = "order2" } }).ExecuteCommand();
|
||||||
var list2 = Db.Queryable<JsonTest>().ToList();
|
var list2 = Db.Queryable<JsonTest>().ToList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -171,6 +171,12 @@ namespace SqlSugar
|
|||||||
this.Context.Ado.ExecuteCommand(string.Format(this.DropTableSql, tableName));
|
this.Context.Ado.ExecuteCommand(string.Format(this.DropTableSql, tableName));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public virtual bool TruncateTable<T>()
|
||||||
|
{
|
||||||
|
this.Context.InitMppingInfo<T>();
|
||||||
|
return this.TruncateTable(this.Context.EntityMaintenance.GetEntityInfo<T>().DbTableName);
|
||||||
|
}
|
||||||
public virtual bool DropColumn(string tableName, string columnName)
|
public virtual bool DropColumn(string tableName, string columnName)
|
||||||
{
|
{
|
||||||
columnName = this.SqlBuilder.GetTranslationColumnName(columnName);
|
columnName = this.SqlBuilder.GetTranslationColumnName(columnName);
|
||||||
|
@ -415,7 +415,11 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
if (this.EntityInfo.Columns.Any(it => it.IsTranscoding))
|
if (this.EntityInfo.Columns.Any(it => it.IsTranscoding))
|
||||||
{
|
{
|
||||||
Check.Exception(true, ErrorMessage.GetThrowMessage("UpdateColumns no support IsTranscoding", "UpdateColumns方式更新不支持IsTranscoding,你可以使用db.Updateable(实体)的方式更新"));
|
Check.Exception(true, ErrorMessage.GetThrowMessage("UpdateColumns no support IsTranscoding", "SetColumns方式更新不支持IsTranscoding,你可以使用db.Updateable(实体)的方式更新"));
|
||||||
|
}
|
||||||
|
if (this.EntityInfo.Columns.Any(it => it.IsJson))
|
||||||
|
{
|
||||||
|
Check.Exception(true, ErrorMessage.GetThrowMessage("UpdateColumns no support IsJson", "SetColumns方式更新不支持IsJson,你可以使用db.Updateable(实体)的方式更新"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void SetUpdateItemByDic(int i, T item, List<DbColumnInfo> updateItem)
|
private void SetUpdateItemByDic(int i, T item, List<DbColumnInfo> updateItem)
|
||||||
|
@ -101,6 +101,19 @@ namespace SqlSugar
|
|||||||
var result = GetNewExpressionValue(item);
|
var result = GetNewExpressionValue(item);
|
||||||
this.Context.Result.Append(base.Context.GetEqString(memberName, result));
|
this.Context.Result.Append(base.Context.GetEqString(memberName, result));
|
||||||
}
|
}
|
||||||
|
else if (item is MemberInitExpression)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var value =ExpressionTool.DynamicInvoke(item);
|
||||||
|
var parameterName = AppendParameter(value);
|
||||||
|
parameter.Context.Result.Append(base.Context.GetEqString(memberName, parameterName));
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
throw new NotSupportedException("Not Supported " + item.ToString() + " " + ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -165,10 +178,10 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool IsSubMethod(MethodCallExpression express)
|
//private bool IsSubMethod(MethodCallExpression express)
|
||||||
{
|
//{
|
||||||
return SubTools.SubItemsConst.Any(it =>express.Object != null && express.Object.Type.Name == "Subqueryable`1");
|
// return SubTools.SubItemsConst.Any(it =>express.Object != null && express.Object.Type.Name == "Subqueryable`1");
|
||||||
}
|
//}
|
||||||
private bool IsExtMethod(string methodName)
|
private bool IsExtMethod(string methodName)
|
||||||
{
|
{
|
||||||
if (this.Context.SqlFuncServices == null) return false;
|
if (this.Context.SqlFuncServices == null) return false;
|
||||||
|
@ -28,6 +28,7 @@ namespace SqlSugar
|
|||||||
#region DDL
|
#region DDL
|
||||||
bool DropTable(string tableName);
|
bool DropTable(string tableName);
|
||||||
bool TruncateTable(string tableName);
|
bool TruncateTable(string tableName);
|
||||||
|
bool TruncateTable<T>();
|
||||||
bool CreateTable(string tableName, List<DbColumnInfo> columns,bool isCreatePrimaryKey=true);
|
bool CreateTable(string tableName, List<DbColumnInfo> columns,bool isCreatePrimaryKey=true);
|
||||||
bool AddColumn(string tableName, DbColumnInfo column);
|
bool AddColumn(string tableName, DbColumnInfo column);
|
||||||
bool UpdateColumn(string tableName, DbColumnInfo column);
|
bool UpdateColumn(string tableName, DbColumnInfo column);
|
||||||
|
Loading…
Reference in New Issue
Block a user