Update Join

This commit is contained in:
sunkaixuan
2023-04-24 12:59:00 +08:00
parent 67ba107bdd
commit 06bad92525
6 changed files with 141 additions and 1 deletions

View File

@@ -34,6 +34,7 @@ namespace SqlSugar
public bool IsWhereColumns { get; set; }
public bool? IsListUpdate { get; set; }
public List<string> UpdateColumns { get; set; }
public List<JoinQueryInfo> JoinInfos { get; set; } = new List<JoinQueryInfo>();
public virtual string SqlTemplate
{

View File

@@ -10,7 +10,7 @@ using System.Threading.Tasks;
namespace SqlSugar
{
public partial class UpdateableProvider<T> : IUpdateable<T> where T : class, new()
public partial class UpdateableProvider<T> : IUpdateable<T> where T : class, new()
{
#region Property
public SqlSugarProvider Context { get; internal set; }
@@ -163,6 +163,14 @@ namespace SqlSugar
#endregion
#region Common
public IUpdateable<T, T2> InnerJoin<T2>(Expression<Func<T, T2, bool>> joinExpress)
{
Updateable<T, T2> result = new Updateable<T, T2>();
result.updateableObj = this;
var querybale=this.Context.Queryable<T>().LeftJoin<T2>(joinExpress);
result.updateableObj.UpdateBuilder.JoinInfos = querybale.QueryBuilder.JoinQueryInfos;
return result;
}
public IUpdateable<T> Clone()
{
this.Context.SugarActionType = SugarActionType.Update;

View File

@@ -0,0 +1,40 @@
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
namespace SqlSugar
{
public class Updateable<T, T2> : IUpdateable<T, T2> where T : class,new()
{
public IUpdateable<T> updateableObj { get; set; }
public int ExecuteCommand()
{
throw new NotImplementedException();
}
public Task<int> ExecuteCommandAsync()
{
throw new NotImplementedException();
}
public IUpdateable<T, T2, T3> InnerJoin<T3>(Expression<Func<T, T2, T3, bool>> joinExpress)
{
throw new NotImplementedException();
}
public IUpdateable<T, T2> SetColumns(Expression<Func<T, T2, T>> columns)
{
// ((UpdateableProvider<T>)updateableObj).SetColumnsByExpression(columns);
return this;
}
public IUpdateable<T, T2> Where(Expression<Func<T, T2, bool>> whereExpression)
{
throw new NotImplementedException();
}
}
}

View File

@@ -0,0 +1,36 @@
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
namespace SqlSugar
{
public class Updateable<T, T2, T3> : IUpdateable<T, T2, T3> where T : class, new()
{
public int ExecuteCommand()
{
throw new NotImplementedException();
}
public Task<int> ExecuteCommandAsync()
{
throw new NotImplementedException();
}
public IUpdateable<T, T2, T3, T4> InnerJoin<T4>(Expression<Func<T, T2, T3, T4, bool>> joinExpress)
{
throw new NotImplementedException();
}
public IUpdateable<T, T2, T3> SetColumns(Expression<Func<T, T2, T3, T>> columns)
{
throw new NotImplementedException();
}
public IUpdateable<T, T2, T3> Where(Expression<Func<T, T2, T3, bool>> whereExpression)
{
throw new NotImplementedException();
}
}
}

View File

@@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
namespace SqlSugar
{
public class Updateable<T, T2, T3, T4> : IUpdateable<T, T2, T3, T4> where T : class, new()
{
public int ExecuteCommand()
{
throw new NotImplementedException();
}
public Task<int> ExecuteCommandAsync()
{
throw new NotImplementedException();
}
public IUpdateable<T, T2, T3, T4> SetColumns(Expression<Func<T, T2, T3, T4, T>> columns)
{
throw new NotImplementedException();
}
public IUpdateable<T, T2, T3, T4> Where(Expression<Func<T, T2, T3, T4, bool>> whereExpression)
{
throw new NotImplementedException();
}
}
}

View File

@@ -110,5 +110,29 @@ namespace SqlSugar
SplitTableUpdateByObjectProvider<T> SplitTable();
IUpdateable<T> EnableQueryFilter();
IUpdateable<T> Clone();
IUpdateable<T,T2> InnerJoin<T2>(Expression<Func<T,T2,bool>> joinExpress);
}
public interface IUpdateable<T, T2>
{
int ExecuteCommand();
Task<int> ExecuteCommandAsync();
IUpdateable<T, T2,T3> InnerJoin<T3>(Expression<Func<T, T2,T3, bool>> joinExpress);
IUpdateable<T, T2> SetColumns(Expression<Func<T, T2,T>> columns);
IUpdateable<T, T2> Where(Expression<Func<T, T2,bool>> whereExpression);
}
public interface IUpdateable<T, T2,T3>
{
IUpdateable<T, T2, T3,T4> InnerJoin<T4>(Expression<Func<T, T2, T3,T4, bool>> joinExpress);
int ExecuteCommand();
Task<int> ExecuteCommandAsync();
IUpdateable<T, T2,T3> SetColumns(Expression<Func<T, T2,T3, T>> columns);
IUpdateable<T, T2,T3> Where(Expression<Func<T, T2,T3, bool>> whereExpression);
}
public interface IUpdateable<T, T2, T3,T4>
{
int ExecuteCommand();
Task<int> ExecuteCommandAsync();
IUpdateable<T, T2, T3,T4> SetColumns(Expression<Func<T, T2, T3,T4, T>> columns);
IUpdateable<T, T2, T3,T4> Where(Expression<Func<T, T2, T3,T4, bool>> whereExpression);
}
}