mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-11-09 02:44:58 +08:00
-
This commit is contained in:
@@ -1,66 +1,79 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Linq.Expressions;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
namespace SqlSugar
|
namespace SqlSugar
|
||||||
{
|
{
|
||||||
public class DeleteBuilder : IDMLBuilder
|
public class DeleteBuilder : IDMLBuilder
|
||||||
{
|
{
|
||||||
public SqlSugarClient Context
|
private List<string> _WhereInfos;
|
||||||
|
|
||||||
|
public SqlSugarClient Context { get; set; }
|
||||||
|
public ILambdaExpressions LambdaExpressions { get; set; }
|
||||||
|
public List<SugarParameter> Parameters { get; set; }
|
||||||
|
public StringBuilder sql { get; set; }
|
||||||
|
public ISqlBuilder Builder { get; set; }
|
||||||
|
public string TableName { get; set; }
|
||||||
|
public string TableWithString { get; set; }
|
||||||
|
public virtual List<string> WhereInfos
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
_WhereInfos = PubMethod.IsNullReturnNew(_WhereInfos);
|
||||||
|
return _WhereInfos;
|
||||||
}
|
}
|
||||||
|
set { _WhereInfos = value; }
|
||||||
set
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public List<SugarParameter> Parameters
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
set
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public StringBuilder sql
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
set
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public string SqlTemplate
|
public string SqlTemplate
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
return " DELETE FROM {0}{1}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public virtual string GetTableNameString
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
var result = Builder.GetTranslationTableName(TableName);
|
||||||
|
result += PubConst.Space;
|
||||||
|
if (this.TableWithString.IsValuable())
|
||||||
|
{
|
||||||
|
result += TableWithString + PubConst.Space;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public virtual string GetWhereString
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_WhereInfos == null || _WhereInfos.Count == 0) return null;
|
||||||
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Clear()
|
public void Clear()
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public string ToSqlString()
|
public string ToSqlString()
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
return string.Format(SqlTemplate, GetTableNameString,GetWhereString);
|
||||||
|
}
|
||||||
|
public virtual ExpressionResult GetExpressionValue(Expression expression, ResolveExpressType resolveType)
|
||||||
|
{
|
||||||
|
ILambdaExpressions resolveExpress = this.LambdaExpressions;
|
||||||
|
this.LambdaExpressions.Clear();
|
||||||
|
resolveExpress.MappingColumns = Context.MappingColumns;
|
||||||
|
resolveExpress.MappingTables = Context.MappingTables;
|
||||||
|
resolveExpress.IgnoreComumnList = Context.IgnoreColumns;
|
||||||
|
resolveExpress.Resolve(expression, resolveType);
|
||||||
|
this.Parameters = new List<SugarParameter>();
|
||||||
|
this.Parameters.AddRange(resolveExpress.Parameters);
|
||||||
|
var reval = resolveExpress.Result;
|
||||||
|
return reval;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ namespace SqlSugar
|
|||||||
public EntityInfo EntityInfo { get; set; }
|
public EntityInfo EntityInfo { get; set; }
|
||||||
public List<MappingColumn> MappingColumnList { get; set; }
|
public List<MappingColumn> MappingColumnList { get; set; }
|
||||||
private List<string> IgnoreColumnNameList { get; set; }
|
private List<string> IgnoreColumnNameList { get; set; }
|
||||||
|
private bool IsOffIdentity { get; set; }
|
||||||
public T[] InsertObjs { get; set; }
|
public T[] InsertObjs { get; set; }
|
||||||
|
|
||||||
#region Core
|
#region Core
|
||||||
@@ -72,7 +73,7 @@ namespace SqlSugar
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IInsertable<T> Where(bool isInsertNull)
|
public IInsertable<T> Where(bool isInsertNull,bool isOffIdentity=false)
|
||||||
{
|
{
|
||||||
if (this.InsertBuilder.LambdaExpressions == null)
|
if (this.InsertBuilder.LambdaExpressions == null)
|
||||||
this.InsertBuilder.LambdaExpressions = InstanceFactory.GetLambdaExpressions(this.Context.CurrentConnectionConfig);
|
this.InsertBuilder.LambdaExpressions = InstanceFactory.GetLambdaExpressions(this.Context.CurrentConnectionConfig);
|
||||||
@@ -85,6 +86,8 @@ namespace SqlSugar
|
|||||||
private void PreToSql()
|
private void PreToSql()
|
||||||
{
|
{
|
||||||
#region Identities
|
#region Identities
|
||||||
|
if (!IsOffIdentity)
|
||||||
|
{
|
||||||
if (this.Context.IsSystemTablesConfig)
|
if (this.Context.IsSystemTablesConfig)
|
||||||
{
|
{
|
||||||
List<string> identities = Db.DbMaintenance.GetIsIdentities(this.InsertBuilder.TableName);
|
List<string> identities = Db.DbMaintenance.GetIsIdentities(this.InsertBuilder.TableName);
|
||||||
@@ -100,6 +103,7 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region IgnoreColumns
|
#region IgnoreColumns
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<ProjectView>ProjectFiles</ProjectView>
|
<ProjectView>ShowAllFiles</ProjectView>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
</Project>
|
</Project>
|
||||||
@@ -267,9 +267,9 @@ namespace SqlSugar
|
|||||||
reval.Context = this;
|
reval.Context = this;
|
||||||
reval.SqlBuilder = sqlBuilder;
|
reval.SqlBuilder = sqlBuilder;
|
||||||
sqlBuilder.DeleteBuilder = reval.DeleteBuilder = InstanceFactory.GetDeleteBuilder(base.CurrentConnectionConfig);
|
sqlBuilder.DeleteBuilder = reval.DeleteBuilder = InstanceFactory.GetDeleteBuilder(base.CurrentConnectionConfig);
|
||||||
sqlBuilder.InsertBuilder.Builder = sqlBuilder;
|
sqlBuilder.DeleteBuilder.Builder = sqlBuilder;
|
||||||
sqlBuilder.InsertBuilder.LambdaExpressions = InstanceFactory.GetLambdaExpressions(base.CurrentConnectionConfig);
|
sqlBuilder.DeleteBuilder.LambdaExpressions = InstanceFactory.GetLambdaExpressions(base.CurrentConnectionConfig);
|
||||||
sqlBuilder.Context = reval.SqlBuilder.InsertBuilder.Context = this;
|
sqlBuilder.Context = reval.SqlBuilder.DeleteBuilder.Context = this;
|
||||||
return reval;
|
return reval;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
Reference in New Issue
Block a user