This commit is contained in:
sunkaixuan 2017-03-04 00:54:19 +08:00
parent 2f3b6b0991
commit ac52b65e10
6 changed files with 34 additions and 9 deletions

13
OrmTest/Config.cs Normal file
View 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";
}
}

View File

@ -27,12 +27,19 @@ namespace OrmTest.ExpressionTest
public void Q2()
{
ExpressionContext contet = new ExpressionContext();
SqlSugarClient db = new SqlSugarClient(new SystemTablesConfig() { ConnectionString="x" ,DbType= DbType.SqlServer });
db.Queryable<Student, School>((st,sc)=> new object[] {
JoinType.Left,st.SchoolId==sc.Id
});
using (var db = GetInstance())
{
var list = db.Queryable<Student, School>((st, sc) => new object[] {
JoinType.Left,st.SchoolId==sc.Id
}).ToList();
}
}
public SqlSugarClient GetInstance()
{
SqlSugarClient db = new SqlSugarClient(new SystemTablesConfig() { ConnectionString = Config.ConnectionString, DbType = DbType.SqlServer });
return db;
}
}
}

View File

@ -43,6 +43,7 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Config.cs" />
<Compile Include="ExpressionTest\ExpTestBase.cs" />
<Compile Include="ExpressionTest\Field.cs" />
<Compile Include="ExpressionTest\Join.cs" />

View File

@ -58,7 +58,11 @@ namespace SqlSugar
{
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;
}
@ -99,7 +103,7 @@ namespace SqlSugar
{
return string.Format(
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.ShortName + " " + TableWithString,
joinInfo.JoinWhere);

View File

@ -55,7 +55,7 @@ namespace SqlSugar
{
sqlCommand.Transaction = (SqlTransaction)this.Transaction;
}
if (pars != null)
if (pars.IsValuable())
{
IDataParameter[] ipars= ToIDbDataParameter(pars);
sqlCommand.Parameters.AddRange((SqlParameter[])ipars);

View File

@ -135,7 +135,7 @@ namespace SqlSugar
var joinString = joinArray[i * 2 - 2];
joinInfo.ShortName = lambdaParameters[i-1].Name;
joinInfo.JoinType = (JoinType) Enum.Parse(typeof (JoinType), joinString);
joinInfo.JoinWhere = joinArray[i * 2];
joinInfo.JoinWhere = joinArray[i * 2-1];
joinInfo.JoinIndex = i;
reval.Add((joinInfo));
}