Browse Source

Update Simple join

pull/12/MERGE
sunkaixuan 7 years ago
parent
commit
89875cf3f1
  1. 12
      Src/Asp.Net/SqlServerTest/UnitTest/Query/JoinQuery.cs
  2. 11
      Src/Asp.Net/SqlSugar/Abstract/SqlBuilderProvider/QueryBuilder.cs
  3. 4
      Src/Asp.Net/SqlSugar/Properties/AssemblyInfo.cs

12
Src/Asp.Net/SqlServerTest/UnitTest/Query/JoinQuery.cs

@ -23,9 +23,21 @@ namespace OrmTest.UnitTest
Q1();
Q2();
Q3();
Q4();
}
base.End("Method Test");
}
private void Q4()
{
using (var db = GetInstance())
{
db.MappingTables.Add("School", "SchoolTable");
var join4 = db.Queryable<Student, School>((st, sc) => st.SchoolId == sc.Id).Select(st=>st).ToSql();
string sql = @"SELECT st.* FROM [STudent] st ,[SchoolTable] sc WHERE ( [st].[SchoolId] = [sc].[Id] ) ";
base.Check(sql, null, join4.Key, null, "join 4 Error");
}
}
private void Q3()
{

11
Src/Asp.Net/SqlSugar/Abstract/SqlBuilderProvider/QueryBuilder.cs

@ -385,13 +385,14 @@ namespace SqlSugar
}
if (this.EasyJoinInfos.IsValuable())
{
if (this.TableWithString.IsValuable())
{
result += "," + string.Join(",", this.EasyJoinInfos.Select(it => string.Format("{0} {1} {2} ", it.Value, it.Key, TableWithString)));
result += "," + string.Join(",", this.EasyJoinInfos.Select(it => string.Format("{0} {1} {2} ",GetTableName(it.Value), it.Key, TableWithString)));
}
else
{
result += "," + string.Join(",", this.EasyJoinInfos.Select(it => string.Format("{0} {1} ", it.Value, it.Key)));
result += "," + string.Join(",", this.EasyJoinInfos.Select(it => string.Format("{0} {1} ", GetTableName(it.Value), it.Key)));
}
}
return result;
@ -425,5 +426,11 @@ namespace SqlSugar
}
}
#endregion
private string GetTableName(string entityName)
{
var result = this.Context.EntityProvider.GetTableName(entityName);
return this.Builder.GetTranslationTableName(result);
}
}
}

4
Src/Asp.Net/SqlSugar/Properties/AssemblyInfo.cs

@ -31,5 +31,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("4.1.1.0")]
[assembly: AssemblyFileVersion("4.1.1.0")]
[assembly: AssemblyVersion("4.1.1.1")]
[assembly: AssemblyFileVersion("4.1.1.1")]

Loading…
Cancel
Save