mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-08-24 07:22:57 +08:00
-
This commit is contained in:
parent
4349eca877
commit
5cede98855
70
Src/Asp.Net/SqlServerTest/BugTest/Bug1.cs
Normal file
70
Src/Asp.Net/SqlServerTest/BugTest/Bug1.cs
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
using OrmTest.Demo;
|
||||||
|
using SqlSugar;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace OrmTest.BugTest
|
||||||
|
{
|
||||||
|
public class Bug1
|
||||||
|
{
|
||||||
|
public static SqlSugarClient GetInstance()
|
||||||
|
{
|
||||||
|
SqlSugarClient db = new SqlSugarClient(new ConnectionConfig()
|
||||||
|
{
|
||||||
|
InitKeyType = InitKeyType.Attribute,
|
||||||
|
ConnectionString = Config.ConnectionString,
|
||||||
|
DbType = DbType.SqlServer,
|
||||||
|
IsAutoCloseConnection = true
|
||||||
|
});
|
||||||
|
db.Aop.OnLogExecuting = (sql, pars) =>
|
||||||
|
{
|
||||||
|
Console.WriteLine(sql + "\r\n" + db.Utilities.SerializeObject(pars.ToDictionary(it => it.ParameterName, it => it.Value)));
|
||||||
|
Console.WriteLine();
|
||||||
|
};
|
||||||
|
return db;
|
||||||
|
}
|
||||||
|
public void Init()
|
||||||
|
{
|
||||||
|
var communityId = "";
|
||||||
|
var buildId = "";
|
||||||
|
var unitId = "";
|
||||||
|
var keyword = "";
|
||||||
|
GetInstance().CodeFirst.InitTables(typeof(MainTable), typeof(SubTable));
|
||||||
|
GetInstance().Queryable<MainTable>().Where(u =>
|
||||||
|
(u.CommunityID == communityId || SqlFunc.IsNullOrEmpty(communityId)) &&
|
||||||
|
(SqlFunc.Contains(u.BuildID, buildId) || SqlFunc.IsNullOrEmpty(buildId)) &&
|
||||||
|
(SqlFunc.Contains(u.UnitID, unitId) || SqlFunc.IsNullOrEmpty(unitId)) &&
|
||||||
|
(SqlFunc.Contains(u.RoomNumber, keyword) || SqlFunc.Contains(u.RoomerName, keyword) ||
|
||||||
|
SqlFunc.Contains(u.HousePlace, keyword) || SqlFunc.Contains(u.UnitName, keyword) ||
|
||||||
|
SqlFunc.Contains(u.BuildName, keyword) || SqlFunc.IsNullOrEmpty(keyword)))
|
||||||
|
.GroupBy(ru => new { ru.RoomNumber, ru.RoomID })
|
||||||
|
.Select(ru => new
|
||||||
|
{
|
||||||
|
RoomNumber = SqlFunc.AggregateMax(ru.RoomNumber),
|
||||||
|
CountRoomer = SqlFunc.AggregateCount(ru.RoomerName),
|
||||||
|
RoomID = SqlFunc.AggregateMax(ru.RoomID),
|
||||||
|
Owner = SqlFunc.Subqueryable<SubTable>().Where(r => r.RoomID == ru.RoomID && SqlFunc.Equals(r.RoomUserType, "业主") && SqlFunc.Equals(r.RoomUserType, "业主")).Select(s => s.RoomerName)
|
||||||
|
}).OrderBy((r) => r.RoomNumber, type: OrderByType.Desc).ToPageList(1, 2);
|
||||||
|
}
|
||||||
|
public class MainTable
|
||||||
|
{
|
||||||
|
public string CommunityID { get; internal set; }
|
||||||
|
public string BuildID { get; internal set; }
|
||||||
|
public string UnitID { get; internal set; }
|
||||||
|
public string RoomNumber { get; internal set; }
|
||||||
|
public string HousePlace { get; internal set; }
|
||||||
|
public string BuildName { get; internal set; }
|
||||||
|
public string RoomID { get; internal set; }
|
||||||
|
public string UnitName { get; internal set; }
|
||||||
|
public string RoomerName { get; internal set; }
|
||||||
|
}
|
||||||
|
public class SubTable
|
||||||
|
{
|
||||||
|
public string RoomID { get; internal set; }
|
||||||
|
public string RoomUserType { get; internal set; }
|
||||||
|
public string RoomerName { get; internal set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -17,6 +17,7 @@ namespace OrmTest
|
|||||||
{
|
{
|
||||||
static void Main(string[] args)
|
static void Main(string[] args)
|
||||||
{
|
{
|
||||||
|
|
||||||
// /***Unit Test***/
|
// /***Unit Test***/
|
||||||
new Select(1).Init();
|
new Select(1).Init();
|
||||||
new Field(1).Init();
|
new Field(1).Init();
|
||||||
@ -53,6 +54,9 @@ namespace OrmTest
|
|||||||
Demo.AttributeDemo.Init();
|
Demo.AttributeDemo.Init();
|
||||||
Demo.Mapper.Init();
|
Demo.Mapper.Init();
|
||||||
Demo.ExtEntity.Init();
|
Demo.ExtEntity.Init();
|
||||||
|
|
||||||
|
/***BUG repair test***/
|
||||||
|
//new BugTest.Bug1().Init();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -47,6 +47,7 @@
|
|||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Compile Include="BugTest\Bug1.cs" />
|
||||||
<Compile Include="Demos\F_VersionValidation.cs" />
|
<Compile Include="Demos\F_VersionValidation.cs" />
|
||||||
<Compile Include="Demos\G_Mapper.cs" />
|
<Compile Include="Demos\G_Mapper.cs" />
|
||||||
<Compile Include="Demos\H_ExtEntity.cs" />
|
<Compile Include="Demos\H_ExtEntity.cs" />
|
||||||
|
Loading…
Reference in New Issue
Block a user