mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-09-19 01:58:13 +08:00
-
This commit is contained in:
@@ -1,66 +1,79 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Text;
|
||||
namespace SqlSugar
|
||||
{
|
||||
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
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
_WhereInfos = PubMethod.IsNullReturnNew(_WhereInfos);
|
||||
return _WhereInfos;
|
||||
}
|
||||
set { _WhereInfos = value; }
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
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()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
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 List<MappingColumn> MappingColumnList { get; set; }
|
||||
private List<string> IgnoreColumnNameList { get; set; }
|
||||
private bool IsOffIdentity { get; set; }
|
||||
public T[] InsertObjs { get; set; }
|
||||
|
||||
#region Core
|
||||
@@ -72,7 +73,7 @@ namespace SqlSugar
|
||||
return this;
|
||||
}
|
||||
|
||||
public IInsertable<T> Where(bool isInsertNull)
|
||||
public IInsertable<T> Where(bool isInsertNull,bool isOffIdentity=false)
|
||||
{
|
||||
if (this.InsertBuilder.LambdaExpressions == null)
|
||||
this.InsertBuilder.LambdaExpressions = InstanceFactory.GetLambdaExpressions(this.Context.CurrentConnectionConfig);
|
||||
@@ -85,20 +86,23 @@ namespace SqlSugar
|
||||
private void PreToSql()
|
||||
{
|
||||
#region Identities
|
||||
if (this.Context.IsSystemTablesConfig)
|
||||
if (!IsOffIdentity)
|
||||
{
|
||||
List<string> identities = Db.DbMaintenance.GetIsIdentities(this.InsertBuilder.TableName);
|
||||
if (identities != null && identities.Any())
|
||||
if (this.Context.IsSystemTablesConfig)
|
||||
{
|
||||
this.InsertBuilder.DbColumnInfoList = this.InsertBuilder.DbColumnInfoList.Where(it =>
|
||||
List<string> identities = Db.DbMaintenance.GetIsIdentities(this.InsertBuilder.TableName);
|
||||
if (identities != null && identities.Any())
|
||||
{
|
||||
return !identities.Any(i => it.ColumnName.Equals(i, StringComparison.CurrentCultureIgnoreCase));
|
||||
}).ToList();
|
||||
this.InsertBuilder.DbColumnInfoList = this.InsertBuilder.DbColumnInfoList.Where(it =>
|
||||
{
|
||||
return !identities.Any(i => it.ColumnName.Equals(i, StringComparison.CurrentCultureIgnoreCase));
|
||||
}).ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<ProjectView>ProjectFiles</ProjectView>
|
||||
<ProjectView>ShowAllFiles</ProjectView>
|
||||
</PropertyGroup>
|
||||
</Project>
|
@@ -267,9 +267,9 @@ namespace SqlSugar
|
||||
reval.Context = this;
|
||||
reval.SqlBuilder = sqlBuilder;
|
||||
sqlBuilder.DeleteBuilder = reval.DeleteBuilder = InstanceFactory.GetDeleteBuilder(base.CurrentConnectionConfig);
|
||||
sqlBuilder.InsertBuilder.Builder = sqlBuilder;
|
||||
sqlBuilder.InsertBuilder.LambdaExpressions = InstanceFactory.GetLambdaExpressions(base.CurrentConnectionConfig);
|
||||
sqlBuilder.Context = reval.SqlBuilder.InsertBuilder.Context = this;
|
||||
sqlBuilder.DeleteBuilder.Builder = sqlBuilder;
|
||||
sqlBuilder.DeleteBuilder.LambdaExpressions = InstanceFactory.GetLambdaExpressions(base.CurrentConnectionConfig);
|
||||
sqlBuilder.Context = reval.SqlBuilder.DeleteBuilder.Context = this;
|
||||
return reval;
|
||||
}
|
||||
#endregion
|
||||
|
Reference in New Issue
Block a user