mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-07-15 05:13:27 +08:00
-
This commit is contained in:
parent
6549a07ea0
commit
dcc026d5bc
@ -62,6 +62,7 @@
|
|||||||
<Compile Include="PerformanceTesting\SqlSugarPerformance.cs" />
|
<Compile Include="PerformanceTesting\SqlSugarPerformance.cs" />
|
||||||
<Compile Include="UnitTest\ExpressionTest\ExpTestBase.cs" />
|
<Compile Include="UnitTest\ExpressionTest\ExpTestBase.cs" />
|
||||||
<Compile Include="UnitTest\ExpressionTest\Field.cs" />
|
<Compile Include="UnitTest\ExpressionTest\Field.cs" />
|
||||||
|
<Compile Include="UnitTest\Insert.cs" />
|
||||||
<Compile Include="UnitTest\Query\JoinQuery.cs" />
|
<Compile Include="UnitTest\Query\JoinQuery.cs" />
|
||||||
<Compile Include="UnitTest\ExpressionTest\Method.cs" />
|
<Compile Include="UnitTest\ExpressionTest\Method.cs" />
|
||||||
<Compile Include="UnitTest\ExpressionTest\Select.cs" />
|
<Compile Include="UnitTest\ExpressionTest\Select.cs" />
|
||||||
|
@ -18,13 +18,13 @@ namespace OrmTest
|
|||||||
static void Main(string[] args)
|
static void Main(string[] args)
|
||||||
{
|
{
|
||||||
//Unit Test
|
//Unit Test
|
||||||
//new Field(1).Init();
|
new Field(1).Init();
|
||||||
//new Where(1).Init();
|
new Where(1).Init();
|
||||||
//new Method(1).Init();
|
new Method(1).Init();
|
||||||
//new JoinQuery(1).Init();
|
new JoinQuery(1).Init();
|
||||||
//new SingleQuery(1).Init();
|
new SingleQuery(1).Init();
|
||||||
//new SelectQuery(1).Init();
|
new SelectQuery(1).Init();
|
||||||
//new AutoClose(200).Init();
|
new AutoClose(1).Init();
|
||||||
|
|
||||||
//Performance Test
|
//Performance Test
|
||||||
//new SqlSugarPerformance(100).Select();
|
//new SqlSugarPerformance(100).Select();
|
||||||
|
52
OrmTest/UnitTest/Insert.cs
Normal file
52
OrmTest/UnitTest/Insert.cs
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
using OrmTest.Models;
|
||||||
|
using SqlSugar;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace OrmTest.UnitTest
|
||||||
|
{
|
||||||
|
public class Insert : ExpTestBase
|
||||||
|
{
|
||||||
|
private Insert() { }
|
||||||
|
public Insert(int eachCount)
|
||||||
|
{
|
||||||
|
this.Count = eachCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Init() {
|
||||||
|
var db = GetInstance();
|
||||||
|
var insertObj = new Student() { Name="jack",CreateTime=DateTime.Now };
|
||||||
|
var insertObjs = new List<Student>() { insertObj }.ToArray();
|
||||||
|
|
||||||
|
//Insert reutrn identity
|
||||||
|
db.Insertable<Student>(insertObj).ExecuteReutrnIdentity();
|
||||||
|
|
||||||
|
//Insert reutrn Command Count
|
||||||
|
db.Insertable<Student>(insertObj).ExecuteCommand();
|
||||||
|
|
||||||
|
//Only insert Name
|
||||||
|
db.Insertable<Student>(insertObj).InsertColumns(it => new object[] { it.Name}).ExecuteReutrnIdentity();
|
||||||
|
|
||||||
|
//Ignore Name and TestId
|
||||||
|
db.Insertable<Student>(insertObj).IgnoreColumns(it => new object[] { it.Name,it.TestId }).ExecuteReutrnIdentity();
|
||||||
|
|
||||||
|
//Use Lock
|
||||||
|
db.Insertable<Student>(insertObj).With(SqlWith.UpdLock).ExecuteCommand();
|
||||||
|
|
||||||
|
//ToSql
|
||||||
|
db.Insertable<Student>(insertObj).With(SqlWith.UpdLock).InsertColumns(it => new object[] { it.Name }).ToSql();
|
||||||
|
|
||||||
|
//Insert List<T>
|
||||||
|
db.Insertable<Student>(insertObjs).With(SqlWith.UpdLock).ExecuteCommand();
|
||||||
|
}
|
||||||
|
|
||||||
|
public SqlSugarClient GetInstance()
|
||||||
|
{
|
||||||
|
SqlSugarClient db = new SqlSugarClient(new SystemTablesConfig() { ConnectionString = Config.ConnectionString, DbType = DbType.SqlServer, IsAutoCloseConnection=true });
|
||||||
|
return db;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -19,6 +19,19 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<SugarParameter> Parameters
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
set
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public StringBuilder sql
|
public StringBuilder sql
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
@ -1,52 +1,57 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using System.Linq;
|
||||||
namespace SqlSugar
|
namespace SqlSugar
|
||||||
{
|
{
|
||||||
public class InsertBuilder : IDMLBuilder
|
public class InsertBuilder : IDMLBuilder
|
||||||
{
|
{
|
||||||
public SqlSugarClient Context
|
public InsertBuilder() {
|
||||||
{
|
this.sql = new StringBuilder();
|
||||||
get
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
set
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
public SqlSugarClient Context { get; set; }
|
||||||
|
public ILambdaExpressions LambdaExpressions { get; set; }
|
||||||
|
public ISqlBuilder Builder { get; set; }
|
||||||
|
public StringBuilder sql { get; set; }
|
||||||
|
public List<SugarParameter> Parameters { get; set; }
|
||||||
|
public string EntityName { get; set; }
|
||||||
|
public string TableWithString { get; set; }
|
||||||
|
public List<string> ColumNames{ get; set; }
|
||||||
|
|
||||||
public StringBuilder sql
|
public virtual string SqlTemplate
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
return @"INSERT INTO {0}
|
||||||
}
|
({1})
|
||||||
|
VALUES
|
||||||
set
|
({2})";
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public string SqlTemplate
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Clear()
|
public void Clear()
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
|
||||||
|
}
|
||||||
|
public virtual string GetTableNameString
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
var result = Builder.GetTranslationTableName(EntityName);
|
||||||
|
result += PubConst.Space;
|
||||||
|
if (this.TableWithString.IsValuable())
|
||||||
|
{
|
||||||
|
result += TableWithString + PubConst.Space;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public string ToSqlString()
|
public string ToSqlString()
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
string columnsString =string.Join("," ,this.ColumNames.Select(it => Builder.GetTranslationColumnName(it)));
|
||||||
|
string columnParametersString = string.Join(",", this.ColumNames.Select(it =>Builder.SqlParameterKeyWord+it));
|
||||||
|
return string.Format(this.sql.ToString(),columnsString, columnParametersString);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ namespace SqlSugar
|
|||||||
|
|
||||||
public QueryBuilder()
|
public QueryBuilder()
|
||||||
{
|
{
|
||||||
this.QueryPars = new List<SugarParameter>();
|
this.Parameters = new List<SugarParameter>();
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Private Fileds
|
#region Private Fileds
|
||||||
@ -42,7 +42,7 @@ namespace SqlSugar
|
|||||||
public string GroupByValue { get; set; }
|
public string GroupByValue { get; set; }
|
||||||
public int WhereIndex { get; set; }
|
public int WhereIndex { get; set; }
|
||||||
public int JoinIndex { get; set; }
|
public int JoinIndex { get; set; }
|
||||||
public virtual List<SugarParameter> QueryPars { get; set; }
|
public virtual List<SugarParameter> Parameters { get; set; }
|
||||||
public virtual List<JoinQueryInfo> JoinQueryInfos
|
public virtual List<JoinQueryInfo> JoinQueryInfos
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@ -191,8 +191,8 @@ namespace SqlSugar
|
|||||||
resolveExpress.MappingTables = Context.MappingTables;
|
resolveExpress.MappingTables = Context.MappingTables;
|
||||||
resolveExpress.IgnoreComumnList = Context.IgnoreComumns;
|
resolveExpress.IgnoreComumnList = Context.IgnoreComumns;
|
||||||
resolveExpress.Resolve(expression, resolveType);
|
resolveExpress.Resolve(expression, resolveType);
|
||||||
this.QueryPars = new List<SugarParameter>();
|
this.Parameters = new List<SugarParameter>();
|
||||||
this.QueryPars.AddRange(resolveExpress.Parameters);
|
this.Parameters.AddRange(resolveExpress.Parameters);
|
||||||
var reval = resolveExpress.Result;
|
var reval = resolveExpress.Result;
|
||||||
return reval;
|
return reval;
|
||||||
}
|
}
|
||||||
@ -234,7 +234,7 @@ namespace SqlSugar
|
|||||||
this.Take = 0;
|
this.Take = 0;
|
||||||
this.sql = null;
|
this.sql = null;
|
||||||
this.WhereIndex = 0;
|
this.WhereIndex = 0;
|
||||||
this.QueryPars = null;
|
this.Parameters = null;
|
||||||
this.GroupByValue = null;
|
this.GroupByValue = null;
|
||||||
this._TableNameString = null;
|
this._TableNameString = null;
|
||||||
this.WhereInfos = null;
|
this.WhereInfos = null;
|
||||||
|
@ -51,6 +51,19 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<SugarParameter> Parameters
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
set
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public string ToSqlString()
|
public string ToSqlString()
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
|
@ -20,6 +20,19 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<SugarParameter> Parameters
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
set
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public StringBuilder sql
|
public StringBuilder sql
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
63
SqlSugar/Abstract/InsertableProvider/InsertableProvider.cs
Normal file
63
SqlSugar/Abstract/InsertableProvider/InsertableProvider.cs
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Linq.Expressions;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SqlSugar
|
||||||
|
{
|
||||||
|
public class InsertableProvider<T> : IInsertable<T> where T : class, new()
|
||||||
|
{
|
||||||
|
public SqlSugarClient Context { get; set; }
|
||||||
|
public IDb Db { get { return Context.Database; } }
|
||||||
|
public IDbBind Bind { get { return this.Db.DbBind; } }
|
||||||
|
public ISqlBuilder SqlBuilder { get; set; }
|
||||||
|
public InsertBuilder InsertBuilder
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return this.SqlBuilder.InsertBuilder;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public int ExecuteCommand()
|
||||||
|
{
|
||||||
|
return Db.ExecuteCommand(InsertBuilder.ToSqlString(), InsertBuilder.Parameters);
|
||||||
|
}
|
||||||
|
public KeyValuePair<string, List<SugarParameter>> ToSql()
|
||||||
|
{
|
||||||
|
string sql = InsertBuilder.ToSqlString();
|
||||||
|
return new KeyValuePair<string, List<SugarParameter>>(sql, InsertBuilder.Parameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int ExecuteReutrnIdentity()
|
||||||
|
{
|
||||||
|
return Db.GetInt(InsertBuilder.ToSqlString(), InsertBuilder.Parameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IInsertable<T> IgnoreColumns(Expression<Func<T, object[]>> columns)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public IInsertable<T> Insert(T InsertObj)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public IInsertable<T> InsertColumns(Expression<Func<T, object[]>> columns)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public IInsertable<T> InsertRange(List<T> InsertObjs)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public IInsertable<T> With(string lockString)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -31,12 +31,12 @@ namespace SqlSugar
|
|||||||
public ISugarQueryable<T> AddParameters(object whereObj)
|
public ISugarQueryable<T> AddParameters(object whereObj)
|
||||||
{
|
{
|
||||||
if (whereObj != null)
|
if (whereObj != null)
|
||||||
QueryBuilder.QueryPars.AddRange(Context.Database.GetParameters(whereObj));
|
QueryBuilder.Parameters.AddRange(Context.Database.GetParameters(whereObj));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
public ISugarQueryable<T> AddParameters(SugarParameter[] pars)
|
public ISugarQueryable<T> AddParameters(SugarParameter[] pars)
|
||||||
{
|
{
|
||||||
QueryBuilder.QueryPars.AddRange(pars);
|
QueryBuilder.Parameters.AddRange(pars);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,7 +71,7 @@ namespace SqlSugar
|
|||||||
var whereValue = QueryBuilder.WhereInfos;
|
var whereValue = QueryBuilder.WhereInfos;
|
||||||
whereValue.Add(SqlBuilder.AppendWhereOrAnd(whereValue.Count == 0, whereString));
|
whereValue.Add(SqlBuilder.AppendWhereOrAnd(whereValue.Count == 0, whereString));
|
||||||
if (whereObj != null)
|
if (whereObj != null)
|
||||||
QueryBuilder.QueryPars.AddRange(Context.Database.GetParameters(whereObj));
|
QueryBuilder.Parameters.AddRange(Context.Database.GetParameters(whereObj));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
public ISugarQueryable<T> Where<T2>(Expression<Func<T2, bool>> expression)
|
public ISugarQueryable<T> Where<T2>(Expression<Func<T2, bool>> expression)
|
||||||
@ -109,7 +109,7 @@ namespace SqlSugar
|
|||||||
|
|
||||||
QueryBuilder.HavingInfos = SqlBuilder.AppendHaving(whereString);
|
QueryBuilder.HavingInfos = SqlBuilder.AppendHaving(whereString);
|
||||||
if (whereObj != null)
|
if (whereObj != null)
|
||||||
QueryBuilder.QueryPars.AddRange(Context.Database.GetParameters(whereObj));
|
QueryBuilder.Parameters.AddRange(Context.Database.GetParameters(whereObj));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
public ISugarQueryable<T> Having<T2>(Expression<Func<T2, bool>> expression)
|
public ISugarQueryable<T> Having<T2>(Expression<Func<T2, bool>> expression)
|
||||||
@ -420,7 +420,7 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
QueryBuilder.IsCount = true;
|
QueryBuilder.IsCount = true;
|
||||||
var sql = QueryBuilder.ToSqlString();
|
var sql = QueryBuilder.ToSqlString();
|
||||||
var reval = Context.Database.GetInt(sql, QueryBuilder.QueryPars.ToArray());
|
var reval = Context.Database.GetInt(sql, QueryBuilder.Parameters.ToArray());
|
||||||
QueryBuilder.IsCount = false;
|
QueryBuilder.IsCount = false;
|
||||||
return reval;
|
return reval;
|
||||||
}
|
}
|
||||||
@ -501,7 +501,7 @@ namespace SqlSugar
|
|||||||
public KeyValuePair<string, List<SugarParameter>> ToSql()
|
public KeyValuePair<string, List<SugarParameter>> ToSql()
|
||||||
{
|
{
|
||||||
string sql = QueryBuilder.ToSqlString();
|
string sql = QueryBuilder.ToSqlString();
|
||||||
return new KeyValuePair<string, List<SugarParameter>>(sql, QueryBuilder.QueryPars);
|
return new KeyValuePair<string, List<SugarParameter>>(sql, QueryBuilder.Parameters);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ISugarQueryable<T> With(string withString)
|
public ISugarQueryable<T> With(string withString)
|
||||||
@ -554,7 +554,7 @@ namespace SqlSugar
|
|||||||
var reval = InstanceFactory.GetQueryable<TResult>(this.Context.CurrentConnectionConfig);
|
var reval = InstanceFactory.GetQueryable<TResult>(this.Context.CurrentConnectionConfig);
|
||||||
reval.Context = this.Context;
|
reval.Context = this.Context;
|
||||||
reval.SqlBuilder = this.SqlBuilder;
|
reval.SqlBuilder = this.SqlBuilder;
|
||||||
reval.SqlBuilder.QueryBuilder.QueryPars = QueryBuilder.QueryPars;
|
reval.SqlBuilder.QueryBuilder.Parameters = QueryBuilder.Parameters;
|
||||||
reval.SqlBuilder.QueryBuilder.SelectValue = expression;
|
reval.SqlBuilder.QueryBuilder.SelectValue = expression;
|
||||||
return reval;
|
return reval;
|
||||||
}
|
}
|
||||||
@ -599,7 +599,7 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var reval = this.Bind.DataReaderToList<TResult>(tType, dataReader, QueryBuilder.SelectCacheKey);
|
result = this.Bind.DataReaderToList<TResult>(tType, dataReader, QueryBuilder.SelectCacheKey);
|
||||||
}
|
}
|
||||||
if (this.Context.CurrentConnectionConfig.IsAutoCloseConnection) this.Context.Close();
|
if (this.Context.CurrentConnectionConfig.IsAutoCloseConnection) this.Context.Close();
|
||||||
}
|
}
|
||||||
|
@ -9,5 +9,11 @@ namespace SqlSugar
|
|||||||
public partial class SqlWith
|
public partial class SqlWith
|
||||||
{
|
{
|
||||||
public const string NoLock = "WITH(NOLOCK) ";
|
public const string NoLock = "WITH(NOLOCK) ";
|
||||||
|
public const string HoldLock = "WITH(HOLDLOCK)";
|
||||||
|
public const string PagLock = "WITH(PAGLOCK)";
|
||||||
|
public const string ReadCommitted = "WITH(READCOMMITTED)";
|
||||||
|
public const string TabLockX = "WITH(TABLOCKX)";
|
||||||
|
public const string UpdLock = "WITH(UPDLOCK)";
|
||||||
|
public const string RowLock = "WITH(ROWLOCK)";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
22
SqlSugar/Interface/IDeleteable.cs
Normal file
22
SqlSugar/Interface/IDeleteable.cs
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Linq.Expressions;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SqlSugar
|
||||||
|
{
|
||||||
|
public interface IDeleteable<T>
|
||||||
|
{
|
||||||
|
int ExecuteCommand();
|
||||||
|
IInsertable<T> TableName(string name);
|
||||||
|
IInsertable<T> With(string lockString);
|
||||||
|
IInsertable<T> Where(T deleteObj);
|
||||||
|
IInsertable<T> Where(Expression<Func<T, bool>> expression);
|
||||||
|
IInsertable<T> Where(List<T> deleteObjs);
|
||||||
|
IInsertable<T> Where<PkType>(PkType primaryKeyValue);
|
||||||
|
IInsertable<T> Where<PkType>(PkType [] primaryKeyValues);
|
||||||
|
IInsertable<T> Where(string whereString,object whereObj);
|
||||||
|
}
|
||||||
|
}
|
@ -8,6 +8,7 @@ namespace SqlSugar
|
|||||||
public partial interface IDMLBuilder
|
public partial interface IDMLBuilder
|
||||||
{
|
{
|
||||||
string SqlTemplate { get; }
|
string SqlTemplate { get; }
|
||||||
|
List<SugarParameter> Parameters { get; set; }
|
||||||
SqlSugarClient Context { get; set; }
|
SqlSugarClient Context { get; set; }
|
||||||
StringBuilder sql { get; set; }
|
StringBuilder sql { get; set; }
|
||||||
string ToSqlString();
|
string ToSqlString();
|
||||||
|
20
SqlSugar/Interface/IUpdateable.cs
Normal file
20
SqlSugar/Interface/IUpdateable.cs
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Linq.Expressions;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SqlSugar
|
||||||
|
{
|
||||||
|
public interface IUpdateable<T>
|
||||||
|
{
|
||||||
|
int ExecuteCommand();
|
||||||
|
IInsertable<T> With(string lockString);
|
||||||
|
IInsertable<T> Update(T InsertObj);
|
||||||
|
IInsertable<T> Where(bool isUpdateNull);
|
||||||
|
IInsertable<T> UpdateColumns(Expression<Func<T, object[]>> columns);
|
||||||
|
IInsertable<T> IgnoreColumns(Expression<Func<T, object[]>> columns);
|
||||||
|
IInsertable<T> UpdateRange(List<T> InsertObjs);
|
||||||
|
}
|
||||||
|
}
|
20
SqlSugar/Interface/Insertable.cs
Normal file
20
SqlSugar/Interface/Insertable.cs
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Linq.Expressions;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SqlSugar
|
||||||
|
{
|
||||||
|
public interface IInsertable<T>
|
||||||
|
{
|
||||||
|
int ExecuteCommand();
|
||||||
|
int ExecuteReutrnIdentity();
|
||||||
|
IInsertable<T> With(string lockString);
|
||||||
|
IInsertable<T> InsertColumns(Expression<Func<T,object []>> columns);
|
||||||
|
IInsertable<T> IgnoreColumns(Expression<Func<T, object[]>> columns);
|
||||||
|
KeyValuePair<string, List<SugarParameter>> ToSql();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -53,6 +53,7 @@
|
|||||||
<Compile Include="Abstract\DbProvider\DbFirstProvider\DbFirstProvider.cs" />
|
<Compile Include="Abstract\DbProvider\DbFirstProvider\DbFirstProvider.cs" />
|
||||||
<Compile Include="Abstract\DbProvider\DbMaintenanceProvider\DbMaintenanceProvider.cs" />
|
<Compile Include="Abstract\DbProvider\DbMaintenanceProvider\DbMaintenanceProvider.cs" />
|
||||||
<Compile Include="Abstract\DbProvider\DbProvider\DbProvider.cs" />
|
<Compile Include="Abstract\DbProvider\DbProvider\DbProvider.cs" />
|
||||||
|
<Compile Include="Abstract\InsertableProvider\InsertableProvider.cs" />
|
||||||
<Compile Include="Entities\Mapping\SugarMappingAttribute.cs" />
|
<Compile Include="Entities\Mapping\SugarMappingAttribute.cs" />
|
||||||
<Compile Include="Abstract\QueryableProvider\QueryableAccessory.cs" />
|
<Compile Include="Abstract\QueryableProvider\QueryableAccessory.cs" />
|
||||||
<Compile Include="Abstract\QueryableProvider\QueryableExtendsions.cs" />
|
<Compile Include="Abstract\QueryableProvider\QueryableExtendsions.cs" />
|
||||||
@ -139,11 +140,14 @@
|
|||||||
<Compile Include="Interface\IDbBind.cs" />
|
<Compile Include="Interface\IDbBind.cs" />
|
||||||
<Compile Include="Interface\IDbFirst.cs" />
|
<Compile Include="Interface\IDbFirst.cs" />
|
||||||
<Compile Include="Interface\IDbMaintenance.cs" />
|
<Compile Include="Interface\IDbMaintenance.cs" />
|
||||||
|
<Compile Include="Interface\IDeleteable.cs" />
|
||||||
<Compile Include="Interface\ILambdaExpressions.cs" />
|
<Compile Include="Interface\ILambdaExpressions.cs" />
|
||||||
|
<Compile Include="Interface\Insertable.cs" />
|
||||||
<Compile Include="Interface\IQueryable.cs" />
|
<Compile Include="Interface\IQueryable.cs" />
|
||||||
<Compile Include="Interface\ISqlBuilder\IDMLBuilder.cs" />
|
<Compile Include="Interface\ISqlBuilder\IDMLBuilder.cs" />
|
||||||
<Compile Include="Interface\ISqlBuilder\ISqlBuilder.cs" />
|
<Compile Include="Interface\ISqlBuilder\ISqlBuilder.cs" />
|
||||||
<Compile Include="Interface\IRewritableMethods.cs" />
|
<Compile Include="Interface\IRewritableMethods.cs" />
|
||||||
|
<Compile Include="Interface\IUpdateable.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="SqlSugarAccessory.cs" />
|
<Compile Include="SqlSugarAccessory.cs" />
|
||||||
<Compile Include="SqlSugarClient.cs" />
|
<Compile Include="SqlSugarClient.cs" />
|
||||||
@ -152,9 +156,8 @@
|
|||||||
<Content Include="Lib\Newtonsoft.Json.dll" />
|
<Content Include="Lib\Newtonsoft.Json.dll" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Folder Include="Abstract\Deleteable\" />
|
<Folder Include="Abstract\DeleteProvider\" />
|
||||||
<Folder Include="Abstract\Insertable\" />
|
<Folder Include="Abstract\UpdateProvider\" />
|
||||||
<Folder Include="Abstract\Updateable\" />
|
|
||||||
<Folder Include="Databases\MySql\" />
|
<Folder Include="Databases\MySql\" />
|
||||||
<Folder Include="Databases\Oracle\" />
|
<Folder Include="Databases\Oracle\" />
|
||||||
<Folder Include="Databases\Sqlite\" />
|
<Folder Include="Databases\Sqlite\" />
|
||||||
|
@ -128,6 +128,21 @@ namespace SqlSugar
|
|||||||
reval.SqlBuilder.QueryBuilder.LambdaExpressions = InstanceFactory.GetLambdaExpressions(base.CurrentConnectionConfig);
|
reval.SqlBuilder.QueryBuilder.LambdaExpressions = InstanceFactory.GetLambdaExpressions(base.CurrentConnectionConfig);
|
||||||
return reval;
|
return reval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public virtual IInsertable<T> Insertable<T>(params T [] insertObj) where T : class, new()
|
||||||
|
{
|
||||||
|
var reval = new InsertableProvider<T>();
|
||||||
|
reval.Context = this;
|
||||||
|
var sqlBuilder = InstanceFactory.GetSqlbuilder(base.CurrentConnectionConfig); ;
|
||||||
|
reval.SqlBuilder = sqlBuilder;
|
||||||
|
reval.SqlBuilder.QueryBuilder = InstanceFactory.GetQueryBuilder(base.CurrentConnectionConfig);
|
||||||
|
reval.SqlBuilder.QueryBuilder.Builder = sqlBuilder;
|
||||||
|
reval.SqlBuilder.Context = reval.SqlBuilder.QueryBuilder.Context = this;
|
||||||
|
reval.SqlBuilder.QueryBuilder.EntityName = typeof(T).Name;
|
||||||
|
reval.SqlBuilder.QueryBuilder.LambdaExpressions = InstanceFactory.GetLambdaExpressions(base.CurrentConnectionConfig);
|
||||||
|
return reval;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Lambda Query operation
|
/// Lambda Query operation
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
Loading…
Reference in New Issue
Block a user