mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-08-24 07:22:57 +08:00
-
This commit is contained in:
parent
2f3b6b0991
commit
ac52b65e10
13
OrmTest/Config.cs
Normal file
13
OrmTest/Config.cs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace OrmTest
|
||||||
|
{
|
||||||
|
public class Config
|
||||||
|
{
|
||||||
|
public static string ConnectionString = "server=.;uid=sa;pwd=sasa;database=SqlSugar4XTest";
|
||||||
|
}
|
||||||
|
}
|
@ -27,12 +27,19 @@ namespace OrmTest.ExpressionTest
|
|||||||
|
|
||||||
public void Q2()
|
public void Q2()
|
||||||
{
|
{
|
||||||
ExpressionContext contet = new ExpressionContext();
|
using (var db = GetInstance())
|
||||||
SqlSugarClient db = new SqlSugarClient(new SystemTablesConfig() { ConnectionString="x" ,DbType= DbType.SqlServer });
|
{
|
||||||
db.Queryable<Student, School>((st,sc)=> new object[] {
|
var list = db.Queryable<Student, School>((st, sc) => new object[] {
|
||||||
JoinType.Left,st.SchoolId==sc.Id
|
JoinType.Left,st.SchoolId==sc.Id
|
||||||
});
|
}).ToList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public SqlSugarClient GetInstance()
|
||||||
|
{
|
||||||
|
SqlSugarClient db = new SqlSugarClient(new SystemTablesConfig() { ConnectionString = Config.ConnectionString, DbType = DbType.SqlServer });
|
||||||
|
return db;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,6 +43,7 @@
|
|||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Compile Include="Config.cs" />
|
||||||
<Compile Include="ExpressionTest\ExpTestBase.cs" />
|
<Compile Include="ExpressionTest\ExpTestBase.cs" />
|
||||||
<Compile Include="ExpressionTest\Field.cs" />
|
<Compile Include="ExpressionTest\Field.cs" />
|
||||||
<Compile Include="ExpressionTest\Join.cs" />
|
<Compile Include="ExpressionTest\Join.cs" />
|
||||||
|
@ -58,7 +58,11 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
if (this.SelectValue.IsNullOrEmpty())
|
if (this.SelectValue.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
return string.Join(",", this.Conext.Database.DbMaintenance.GetColumnInfosByTableName(this.EntityName).Select(it => this.Conext.SqlBuilder.GetTranslationColumnName(it.ColumnName)));
|
string pre = null;
|
||||||
|
if (this.JoinQueryInfos.IsValuable() && this.JoinQueryInfos.Any(it => it.PreShortName.IsValuable())) {
|
||||||
|
pre = this.Conext.SqlBuilder.GetTranslationColumnName(this.JoinQueryInfos.Single(it => it.PreShortName.IsValuable()).PreShortName)+".";
|
||||||
|
}
|
||||||
|
return string.Join(",", this.Conext.Database.DbMaintenance.GetColumnInfosByTableName(this.EntityName).Select(it => pre+this.Conext.SqlBuilder.GetTranslationColumnName(it.ColumnName)));
|
||||||
}
|
}
|
||||||
else return this.SelectValue;
|
else return this.SelectValue;
|
||||||
}
|
}
|
||||||
@ -99,7 +103,7 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
return string.Format(
|
return string.Format(
|
||||||
this.JoinTemplate,
|
this.JoinTemplate,
|
||||||
joinInfo.JoinIndex == 0 ? (joinInfo.PreShortName + " " + joinInfo.JoinType.ToString()+" ") : (joinInfo.JoinType.ToString() + " JOIN "),
|
joinInfo.JoinIndex == 1 ? (joinInfo.PreShortName + " " + joinInfo.JoinType.ToString()+" ") : (joinInfo.JoinType.ToString() + " JOIN "),
|
||||||
joinInfo.TableName,
|
joinInfo.TableName,
|
||||||
joinInfo.ShortName + " " + TableWithString,
|
joinInfo.ShortName + " " + TableWithString,
|
||||||
joinInfo.JoinWhere);
|
joinInfo.JoinWhere);
|
||||||
|
@ -55,7 +55,7 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
sqlCommand.Transaction = (SqlTransaction)this.Transaction;
|
sqlCommand.Transaction = (SqlTransaction)this.Transaction;
|
||||||
}
|
}
|
||||||
if (pars != null)
|
if (pars.IsValuable())
|
||||||
{
|
{
|
||||||
IDataParameter[] ipars= ToIDbDataParameter(pars);
|
IDataParameter[] ipars= ToIDbDataParameter(pars);
|
||||||
sqlCommand.Parameters.AddRange((SqlParameter[])ipars);
|
sqlCommand.Parameters.AddRange((SqlParameter[])ipars);
|
||||||
|
@ -135,7 +135,7 @@ namespace SqlSugar
|
|||||||
var joinString = joinArray[i * 2 - 2];
|
var joinString = joinArray[i * 2 - 2];
|
||||||
joinInfo.ShortName = lambdaParameters[i-1].Name;
|
joinInfo.ShortName = lambdaParameters[i-1].Name;
|
||||||
joinInfo.JoinType = (JoinType) Enum.Parse(typeof (JoinType), joinString);
|
joinInfo.JoinType = (JoinType) Enum.Parse(typeof (JoinType), joinString);
|
||||||
joinInfo.JoinWhere = joinArray[i * 2];
|
joinInfo.JoinWhere = joinArray[i * 2-1];
|
||||||
joinInfo.JoinIndex = i;
|
joinInfo.JoinIndex = i;
|
||||||
reval.Add((joinInfo));
|
reval.Add((joinInfo));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user