db.Queryable(queryable1,queryable2) Filter bug

This commit is contained in:
sunkaixuna
2021-07-19 13:19:26 +08:00
parent 109454c56c
commit 65ea005311
2 changed files with 76 additions and 24 deletions

View File

@@ -87,7 +87,8 @@ namespace OrmTest
id = it.Id,
name = it.Name
}).MergeTable()
.Where(it=>2>it.id).Select(it=> new Order() {
.Where(it => 2 > it.id).Select(it => new Order()
{
Id = SqlFunc.IIF(2 > it.id, 1, 2)
}).ToList();
@@ -116,15 +117,64 @@ namespace OrmTest
Db.Insertable(new ABMap() { Aid = 2, Bid = 2 }).ExecuteCommand();
var list9 = Db.Queryable<TableA>()
.Mapper<TableA, TableB, ABMap>(it => ManyToMany.Config(it.Aid, it.Bid)).ToList();
var _db = Db;
int[] communities = { 1, 2, 3, 4, 5 };
_db.QueryFilter.Add(new TableFilterItem<Dat_WorkBill>(it => communities.Contains(it.CommunityID ?? 0)));
Db.CodeFirst.InitTables<Dat_WorkBill, Base_Community>();
var rlt = _db.Queryable(_db.Queryable<Dat_WorkBill>(), _db.Queryable<Base_Community>(),
JoinType.Left, (bill, com) => bill.CommunityID == com.CommunityID)
.Where((bill, com) => com.IsEnable == 1)
.Select((bill, com) => new
{
ID = bill.WorkBillID,
Name = com.CommunityName
})
.ToList();
_db.QueryFilter.Clear();
}
public class Dat_WorkBill
{
public int? CommunityID { get; set; }
public string WorkBillID { get; set; }
}
public class Base_Community
{
public int? CommunityID { get; set; }
public int IsEnable { get; set; }
public string CommunityName { get; set; }
}
public class ABMap{
public class ABMap
{
public int Aid { get; set; }
public int Bid { get; set; }
}
public class TableA{
public class TableA
{
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
public int id { get; set; }

View File

@@ -357,6 +357,8 @@ namespace SqlSugar
}
else if (isMain)
{
if (TableShortName == null)
return;
var shortName = this.Builder.GetTranslationColumnName(TableShortName) + ".";
sql = sql.Replace(itName, shortName);
}