Browse Source

Optimize API

pull/31/head
sunkaixuan 2 years ago
parent
commit
965819abcd
  1. 14
      Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableExecuteSql.cs
  2. 27
      Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableProvider.cs
  3. 9
      Src/Asp.Net/SqlSugar/Interface/IQueryable.cs
  4. 2
      Src/Asp.Net/SqlSugar/SqlSugar.nuspec

14
Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableExecuteSql.cs

@ -733,15 +733,15 @@ namespace SqlSugar
return result;
}
public bool IntoTable<TableEntityType>()
public int IntoTable<TableEntityType>()
{
return IntoTable(typeof(TableEntityType));
}
public bool IntoTable<TableEntityType>(string TableName)
public int IntoTable<TableEntityType>(string TableName)
{
return IntoTable(typeof(TableEntityType), TableName);
}
public bool IntoTable(Type TableEntityType)
public int IntoTable(Type TableEntityType)
{
var entityInfo=this.Context.EntityMaintenance.GetEntityInfo(TableEntityType);
var sqlInfo=this.ToSql();
@ -758,11 +758,10 @@ namespace SqlSugar
columns = columns.TrimEnd(',') + ")";
}
var sql= $" INSERT INTO {name} {columns} " + sqlInfo.Key;
this.Context.Ado.ExecuteCommand(sql, sqlInfo.Value);
return true;
return this.Context.Ado.ExecuteCommand(sql, sqlInfo.Value);
}
public bool IntoTable(Type TableEntityType,string TableName)
public int IntoTable(Type TableEntityType,string TableName)
{
//var entityInfo = this.Context.EntityMaintenance.GetEntityInfo(TableEntityType);
var sqlInfo = this.ToSql();
@ -779,8 +778,7 @@ namespace SqlSugar
columns = columns.TrimEnd(',') + ")";
}
var sql = $" INSERT INTO {name} {columns} " + sqlInfo.Key;
this.Context.Ado.ExecuteCommand(sql, sqlInfo.Value);
return true;
return this.Context.Ado.ExecuteCommand(sql, sqlInfo.Value);
}
}

27
Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableProvider.cs

@ -30,13 +30,13 @@ namespace SqlSugar
this.QueryBuilder.CrossQueryItems.Add(type.FullName, configId);
return this;
}
public ISugarQueryable<T> IncludeLeftJoin(Expression<Func<T, object>> LeftObject)
public ISugarQueryable<T> IncludeLeftJoin(Expression<Func<T, object>> leftObjectExp)
{
MemberExpression memberExpression;
string navObjectName;
EntityColumnInfo navColumn, navPkColumn;
EntityInfo navEntityInfo;
ExpressionTool.GetOneToOneInfo(this.Context,LeftObject, out memberExpression, out navObjectName, out navColumn, out navEntityInfo, out navPkColumn);
ExpressionTool.GetOneToOneInfo(this.Context, leftObjectExp, out memberExpression, out navObjectName, out navColumn, out navEntityInfo, out navPkColumn);
var shortName = $"pnv_{navObjectName}";
var mainShortName = memberExpression.Expression.ToString();
this.QueryBuilder.TableShortName = mainShortName;
@ -45,13 +45,13 @@ namespace SqlSugar
this.AddJoinInfo(navEntityInfo.DbTableName, shortName, onWhere, JoinType.Left);
return this;
}
public ISugarQueryable<T> IncludeInnerJoin(Expression<Func<T, object>> LeftObject)
public ISugarQueryable<T> IncludeInnerJoin(Expression<Func<T, object>> innerObjectExt)
{
MemberExpression memberExpression;
string navObjectName;
EntityColumnInfo navColumn, navPkColumn;
EntityInfo navEntityInfo;
ExpressionTool.GetOneToOneInfo(this.Context, LeftObject, out memberExpression, out navObjectName, out navColumn, out navEntityInfo, out navPkColumn);
ExpressionTool.GetOneToOneInfo(this.Context, innerObjectExt, out memberExpression, out navObjectName, out navColumn, out navEntityInfo, out navPkColumn);
var shortName = $"pnv_{navObjectName}";
var mainShortName = memberExpression.Expression.ToString();
this.QueryBuilder.TableShortName = mainShortName;
@ -60,13 +60,13 @@ namespace SqlSugar
this.AddJoinInfo(navEntityInfo.DbTableName, shortName, onWhere, JoinType.Inner);
return this;
}
public ISugarQueryable<T> IncludeFullJoin(Expression<Func<T, object>> LeftObject)
public ISugarQueryable<T> IncludeFullJoin(Expression<Func<T, object>> fullObjectExp)
{
MemberExpression memberExpression;
string navObjectName;
EntityColumnInfo navColumn, navPkColumn;
EntityInfo navEntityInfo;
ExpressionTool.GetOneToOneInfo(this.Context, LeftObject, out memberExpression, out navObjectName, out navColumn, out navEntityInfo, out navPkColumn);
ExpressionTool.GetOneToOneInfo(this.Context, fullObjectExp, out memberExpression, out navObjectName, out navColumn, out navEntityInfo, out navPkColumn);
var shortName = $"pnv_{navObjectName}";
var mainShortName = memberExpression.Expression.ToString();
this.QueryBuilder.TableShortName = mainShortName;
@ -75,6 +75,21 @@ namespace SqlSugar
this.AddJoinInfo(navEntityInfo.DbTableName, shortName, onWhere, JoinType.Full);
return this;
}
public ISugarQueryable<T> IncludeRightJoin(Expression<Func<T, object>> rightObjectExp)
{
MemberExpression memberExpression;
string navObjectName;
EntityColumnInfo navColumn, navPkColumn;
EntityInfo navEntityInfo;
ExpressionTool.GetOneToOneInfo(this.Context, rightObjectExp, out memberExpression, out navObjectName, out navColumn, out navEntityInfo, out navPkColumn);
var shortName = $"pnv_{navObjectName}";
var mainShortName = memberExpression.Expression.ToString();
this.QueryBuilder.TableShortName = mainShortName;
var onWhere = $"{shortName}.{navPkColumn.DbColumnName}={mainShortName}.{navColumn.DbColumnName}";
UtilMethods.IsNullReturnNew(this.Context.TempItems);
this.AddJoinInfo(navEntityInfo.DbTableName, shortName, onWhere, JoinType.Right);
return this;
}
public ISugarQueryable<T, T2> LeftJoin<T2>(ISugarQueryable<T2> joinQueryable, Expression<Func<T, T2, bool>> joinExpression)
{

9
Src/Asp.Net/SqlSugar/Interface/IQueryable.cs

@ -24,6 +24,7 @@ namespace SqlSugar
ISugarQueryable<T> CrossQuery<Type>(string configId);
ISugarQueryable<T> CrossQuery(Type type ,string configId);
ISugarQueryable<T> IncludeLeftJoin(Expression<Func<T, object>> leftObjectExp);
ISugarQueryable<T> IncludeInnerJoin(Expression<Func<T, object>> innerObjectExp);
ISugarQueryable<T> IncludeRightJoin(Expression<Func<T, object>> rightObjectExp);
ISugarQueryable<T> IncludeFullJoin(Expression<Func<T, object>> fullObjectExp);
ISugarQueryable<T, T2> LeftJoin<T2>(ISugarQueryable<T2> joinQueryable, Expression<Func<T, T2, bool>> joinExpression);
@ -162,10 +163,10 @@ namespace SqlSugar
Task<List<TResult>> ToListAsync<TResult>(Expression<Func<T, TResult>> expression);
List<T> ToList();
bool IntoTable<TableEntityType>();
bool IntoTable(Type TableEntityType);
bool IntoTable<TableEntityType>(string tableName);
bool IntoTable(Type TableEntityType,string tableName);
int IntoTable<TableEntityType>();
int IntoTable(Type TableEntityType);
int IntoTable<TableEntityType>(string tableName);
int IntoTable(Type TableEntityType,string tableName);
//bool IntoTable(Type TableEntityType, params string[] columnNameList);
//bool IntoTable<TableEntityType>(params string[] columnNameList);
List<T> SetContext<ParameterT>(Expression<Func<T, bool>> whereExpression, ParameterT parameter);

2
Src/Asp.Net/SqlSugar/SqlSugar.nuspec

@ -2,7 +2,7 @@
<package >
<metadata>
<id>SqlSugar</id>
<version>5.1.3.52</version>
<version>5.1.3.53</version>
<title>.Net Framework 安装此版本, 5.0.3.3-max 最低要求 .Net Framework 4.6 | 5.0.0.2-5.0.3.2 最低要求 .Net Framework 4.5 | 4.0-4.9.11 最低要求 .Net Framework 4.0+ .NET ORM </title>
<authors>sun kaixuan</authors>
<owners>landa</owners>

Loading…
Cancel
Save