mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-09-23 04:23:47 +08:00
join update
This commit is contained in:
@@ -1076,7 +1076,7 @@ namespace SqlSugar
|
|||||||
return sql;
|
return sql;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected JoinQueryInfo GetJoinInfo(Expression joinExpression, JoinType joinType)
|
internal JoinQueryInfo GetJoinInfo(Expression joinExpression, JoinType joinType)
|
||||||
{
|
{
|
||||||
QueryBuilder.CheckExpressionNew(joinExpression, "Join");
|
QueryBuilder.CheckExpressionNew(joinExpression, "Join");
|
||||||
QueryBuilder.JoinExpression = joinExpression;
|
QueryBuilder.JoinExpression = joinExpression;
|
||||||
|
@@ -165,7 +165,7 @@ namespace SqlSugar
|
|||||||
#region Common
|
#region Common
|
||||||
public IUpdateable<T, T2> InnerJoin<T2>(Expression<Func<T, T2, bool>> joinExpress)
|
public IUpdateable<T, T2> InnerJoin<T2>(Expression<Func<T, T2, bool>> joinExpress)
|
||||||
{
|
{
|
||||||
Updateable<T, T2> result = new Updateable<T, T2>();
|
UpdateableProvider<T, T2> result = new UpdateableProvider<T, T2>();
|
||||||
result.updateableObj = this;
|
result.updateableObj = this;
|
||||||
var querybale=this.Context.Queryable<T>().LeftJoin<T2>(joinExpress);
|
var querybale=this.Context.Queryable<T>().LeftJoin<T2>(joinExpress);
|
||||||
result.updateableObj.UpdateBuilder.JoinInfos = querybale.QueryBuilder.JoinQueryInfos;
|
result.updateableObj.UpdateBuilder.JoinInfos = querybale.QueryBuilder.JoinQueryInfos;
|
||||||
|
@@ -9,9 +9,9 @@ using System.Threading.Tasks;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
namespace SqlSugar
|
namespace SqlSugar
|
||||||
{
|
{
|
||||||
public class Updateable<T, T2> : IUpdateable<T, T2> where T : class,new()
|
public class UpdateableProvider<T, T2> : IUpdateable<T, T2> where T : class,new()
|
||||||
{
|
{
|
||||||
public IUpdateable<T> updateableObj { get; set; }
|
public IUpdateable<T> updateableObj { get; set; }
|
||||||
public int ExecuteCommand()
|
public int ExecuteCommand()
|
||||||
{
|
{
|
||||||
return this.updateableObj.ExecuteCommand();
|
return this.updateableObj.ExecuteCommand();
|
||||||
@@ -24,7 +24,12 @@ namespace SqlSugar
|
|||||||
|
|
||||||
public IUpdateable<T, T2, T3> InnerJoin<T3>(Expression<Func<T, T2, T3, bool>> joinExpress)
|
public IUpdateable<T, T2, T3> InnerJoin<T3>(Expression<Func<T, T2, T3, bool>> joinExpress)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
UpdateableProvider<T, T2,T3> result = new UpdateableProvider<T, T2,T3>();
|
||||||
|
result.updateableObj = updateableObj;
|
||||||
|
var joinIno = ((QueryableProvider<T>)updateableObj.UpdateBuilder.Context.Queryable<T>()).GetJoinInfo(joinExpress, JoinType.Inner);
|
||||||
|
result.updateableObj.UpdateBuilder.JoinInfos.Add(joinIno);
|
||||||
|
result.updateableObj.UpdateBuilder.ShortName = joinExpress.Parameters.FirstOrDefault()?.Name;
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IUpdateable<T, T2> SetColumns(Expression<Func<T, T2, T>> columns)
|
public IUpdateable<T, T2> SetColumns(Expression<Func<T, T2, T>> columns)
|
||||||
|
@@ -3,34 +3,56 @@ using System.Collections.Generic;
|
|||||||
using System.Linq.Expressions;
|
using System.Linq.Expressions;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using System.Linq;
|
||||||
namespace SqlSugar
|
namespace SqlSugar
|
||||||
{
|
{
|
||||||
public class Updateable<T, T2, T3> : IUpdateable<T, T2, T3> where T : class, new()
|
public class UpdateableProvider<T, T2, T3> : IUpdateable<T, T2, T3> where T : class, new()
|
||||||
{
|
{
|
||||||
|
internal IUpdateable<T> updateableObj;
|
||||||
|
|
||||||
public int ExecuteCommand()
|
public int ExecuteCommand()
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
return this.updateableObj.ExecuteCommand();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<int> ExecuteCommandAsync()
|
public Task<int> ExecuteCommandAsync()
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
return this.updateableObj.ExecuteCommandAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
public IUpdateable<T, T2, T3, T4> InnerJoin<T4>(Expression<Func<T, T2, T3, T4, bool>> joinExpress)
|
public IUpdateable<T, T2, T3, T4> InnerJoin<T4>(Expression<Func<T, T2, T3, T4, bool>> joinExpress)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
UpdateableProvider<T, T2, T3,T4> result = new UpdateableProvider<T, T2, T3,T4>();
|
||||||
|
result.updateableObj = updateableObj;
|
||||||
|
var joinIno = ((QueryableProvider<T>)updateableObj.UpdateBuilder.Context.Queryable<T>()).GetJoinInfo(joinExpress, JoinType.Inner);
|
||||||
|
result.updateableObj.UpdateBuilder.JoinInfos.Add(joinIno);
|
||||||
|
result.updateableObj.UpdateBuilder.ShortName = joinExpress.Parameters.FirstOrDefault()?.Name;
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IUpdateable<T, T2, T3> SetColumns(Expression<Func<T, T2, T3, T>> columns)
|
public IUpdateable<T, T2, T3> SetColumns(Expression<Func<T, T2, T3, T>> columns)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
var exp = ((columns as LambdaExpression).Body as MemberInitExpression).Bindings;
|
||||||
|
var items = ExpressionTool.GetMemberBindingItemList(exp);
|
||||||
|
var UpdateBuilder = updateableObj.UpdateBuilder;
|
||||||
|
var SqlBuilder = UpdateBuilder.Builder;
|
||||||
|
foreach (var item in items)
|
||||||
|
{
|
||||||
|
var dbColumnName = updateableObj.UpdateBuilder.Context.EntityMaintenance.GetDbColumnName<T>(item.Key);
|
||||||
|
var value = updateableObj.UpdateBuilder.GetExpressionValue(ExpressionTool.RemoveConvert(item.Value), ResolveExpressType.WhereMultiple).GetString();
|
||||||
|
this.updateableObj.UpdateBuilder.SetValues.Add(new KeyValuePair<string, string>(dbColumnName, value));
|
||||||
|
}
|
||||||
|
UpdateBuilder.DbColumnInfoList = UpdateBuilder.DbColumnInfoList
|
||||||
|
.Where(it => it.UpdateServerTime == true || it.UpdateSql.HasValue() || UpdateBuilder.SetValues.Any(v => SqlBuilder.GetNoTranslationColumnName(v.Key).Equals(it.DbColumnName, StringComparison.CurrentCultureIgnoreCase) || SqlBuilder.GetNoTranslationColumnName(v.Key).Equals(it.PropertyName, StringComparison.CurrentCultureIgnoreCase)) || it.IsPrimarykey == true).ToList();
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IUpdateable<T, T2, T3> Where(Expression<Func<T, T2, T3, bool>> whereExpression)
|
public IUpdateable<T, T2, T3> Where(Expression<Func<T, T2, T3, bool>> whereExpression)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
|
||||||
|
var value = updateableObj.UpdateBuilder.GetExpressionValue(whereExpression, ResolveExpressType.WhereMultiple).GetString();
|
||||||
|
updateableObj.UpdateBuilder.WhereValues.Add(value);
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -3,29 +3,45 @@ using System.Collections.Generic;
|
|||||||
using System.Linq.Expressions;
|
using System.Linq.Expressions;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using System.Linq;
|
||||||
namespace SqlSugar
|
namespace SqlSugar
|
||||||
{
|
{
|
||||||
public class Updateable<T, T2, T3, T4> : IUpdateable<T, T2, T3, T4> where T : class, new()
|
public class UpdateableProvider<T, T2, T3, T4> : IUpdateable<T, T2, T3, T4> where T : class, new()
|
||||||
{
|
{
|
||||||
|
public IUpdateable<T> updateableObj { get; set; }
|
||||||
public int ExecuteCommand()
|
public int ExecuteCommand()
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
return this.updateableObj.ExecuteCommand();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<int> ExecuteCommandAsync()
|
public Task<int> ExecuteCommandAsync()
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
return this.updateableObj.ExecuteCommandAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
public IUpdateable<T, T2, T3, T4> SetColumns(Expression<Func<T, T2, T3, T4, T>> columns)
|
public IUpdateable<T, T2, T3, T4> SetColumns(Expression<Func<T, T2, T3, T4, T>> columns)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
var exp = ((columns as LambdaExpression).Body as MemberInitExpression).Bindings;
|
||||||
|
var items = ExpressionTool.GetMemberBindingItemList(exp);
|
||||||
|
var UpdateBuilder = updateableObj.UpdateBuilder;
|
||||||
|
var SqlBuilder = UpdateBuilder.Builder;
|
||||||
|
foreach (var item in items)
|
||||||
|
{
|
||||||
|
var dbColumnName = updateableObj.UpdateBuilder.Context.EntityMaintenance.GetDbColumnName<T>(item.Key);
|
||||||
|
var value = updateableObj.UpdateBuilder.GetExpressionValue(ExpressionTool.RemoveConvert(item.Value), ResolveExpressType.WhereMultiple).GetString();
|
||||||
|
this.updateableObj.UpdateBuilder.SetValues.Add(new KeyValuePair<string, string>(dbColumnName, value));
|
||||||
|
}
|
||||||
|
UpdateBuilder.DbColumnInfoList = UpdateBuilder.DbColumnInfoList
|
||||||
|
.Where(it => it.UpdateServerTime == true || it.UpdateSql.HasValue() || UpdateBuilder.SetValues.Any(v => SqlBuilder.GetNoTranslationColumnName(v.Key).Equals(it.DbColumnName, StringComparison.CurrentCultureIgnoreCase) || SqlBuilder.GetNoTranslationColumnName(v.Key).Equals(it.PropertyName, StringComparison.CurrentCultureIgnoreCase)) || it.IsPrimarykey == true).ToList();
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IUpdateable<T, T2, T3, T4> Where(Expression<Func<T, T2, T3, T4, bool>> whereExpression)
|
public IUpdateable<T, T2, T3, T4> Where(Expression<Func<T, T2, T3, T4, bool>> whereExpression)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
|
||||||
|
var value = updateableObj.UpdateBuilder.GetExpressionValue(whereExpression, ResolveExpressType.WhereMultiple).GetString();
|
||||||
|
updateableObj.UpdateBuilder.WhereValues.Add(value);
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user