From 036b6288f4a15a612181a8ef3db9be9ea524112f Mon Sep 17 00:00:00 2001
From: sunkaixuan <610262374@qq.com>
Date: Tue, 19 Dec 2017 16:20:35 +0800
Subject: [PATCH] Expression Bug
---
.../SqlServerTest/Models/CapitalEntity.cs | 517 ++++++++++++++++++
.../SqlServerTest/SqlServerTest.csproj | 1 +
.../UnitTest/Query/SingleQuery.cs | 13 +
.../MethodCallExpressionResolve.cs | 6 +-
4 files changed, 536 insertions(+), 1 deletion(-)
create mode 100644 Src/Asp.Net/SqlServerTest/Models/CapitalEntity.cs
diff --git a/Src/Asp.Net/SqlServerTest/Models/CapitalEntity.cs b/Src/Asp.Net/SqlServerTest/Models/CapitalEntity.cs
new file mode 100644
index 000000000..1eff4c9e6
--- /dev/null
+++ b/Src/Asp.Net/SqlServerTest/Models/CapitalEntity.cs
@@ -0,0 +1,517 @@
+using SqlSugar;
+using System;
+using System.Linq;
+using System.Text;
+
+
+namespace OrmTest.Models
+{
+ [SugarTable("RENT_CAPITAL")]
+ public partial class CapitalEntity
+ {
+ public CapitalEntity()
+ {
+
+ }
+
+
+ ///
+ /// Desc:-
+ /// Default:-
+ /// Nullable:False
+ ///
+ [SugarColumn(IsPrimaryKey=true)]
+ public string QrfId {get;set;}
+
+ ///
+ /// Desc:-
+ /// Default:-
+ /// Nullable:True
+ ///
+ public string RiseId {get;set;}
+
+ ///
+ /// Desc:-
+ /// Default:-
+ /// Nullable:True
+ ///
+ public string Quart {get;set;}
+
+ ///
+ /// Desc:-
+ /// Default:-
+ /// Nullable:True
+ ///
+ public string Rise {get;set;}
+
+ ///
+ /// Desc:-
+ /// Default:-
+ /// Nullable:True
+ ///
+ public string Flat {get;set;}
+
+ ///
+ /// Desc:-
+ /// Default:-
+ /// Nullable:True
+ ///
+ public string QrfCode {get;set;}
+
+ ///
+ /// Desc:-
+ /// Default:-
+ /// Nullable:True
+ ///
+ public string QrfName {get;set;}
+
+ ///
+ /// Desc:-
+ /// Default:-
+ /// Nullable:True
+ ///
+ public string ComProp {get;set;}
+
+ ///
+ /// Desc:-
+ /// Default:-
+ /// Nullable:True
+ ///
+ public string HallProp {get;set;}
+
+ ///
+ /// Desc:-
+ /// Default:-
+ /// Nullable:True
+ ///
+ public string FlatProp {get;set;}
+
+ ///
+ /// Desc:-
+ /// Default:-
+ /// Nullable:True
+ ///
+ public string Flatsrc {get;set;}
+
+ ///
+ /// Desc:-
+ /// Default:-
+ /// Nullable:True
+ ///
+ public string Flatbus {get;set;}
+
+ ///
+ /// Desc:-
+ /// Default:-
+ /// Nullable:True
+ ///
+ public string Flatfund {get;set;}
+
+ ///
+ /// Desc:-
+ /// Default:-
+ /// Nullable:True
+ ///
+ public decimal? Keynum {get;set;}
+
+ ///
+ /// Desc:-
+ /// Default:-
+ /// Nullable:True
+ ///
+ public decimal? Areas {get;set;}
+
+ ///
+ /// Desc:-
+ /// Default:-
+ /// Nullable:True
+ ///
+ public string FlatStatus {get;set;}
+
+ ///
+ /// Desc:-
+ /// Default:-
+ /// Nullable:True
+ ///
+ public string FlatstatusFix {get;set;}
+
+ ///
+ /// Desc:-
+ /// Default:-
+ /// Nullable:True
+ ///
+ public string FlatstatusAllo {get;set;}
+
+ ///
+ /// Desc:-
+ /// Default:-
+ /// Nullable:True
+ ///
+ public string FlatalloProp {get;set;}
+
+ ///
+ /// Desc:-
+ /// Default:-
+ /// Nullable:True
+ ///
+ public string FaceProp {get;set;}
+
+ ///
+ /// Desc:-
+ /// Default:-
+ /// Nullable:True
+ ///
+ public decimal? Facepara {get;set;}
+
+ ///
+ /// Desc:-
+ /// Default:-
+ /// Nullable:True
+ ///
+ public decimal? Floorpara {get;set;}
+
+ ///
+ /// Desc:-
+ /// Default:-
+ /// Nullable:True
+ ///
+ public string Prcbymode {get;set;}
+
+ ///
+ /// Desc:-
+ /// Default:-
+ /// Nullable:True
+ ///
+ public decimal? PrcBase {get;set;}
+
+ ///
+ /// Desc:-
+ /// Default:-
+ /// Nullable:True
+ ///
+ public decimal? PrcLimt {get;set;}
+
+ ///
+ /// Desc:-
+ /// Default:-
+ /// Nullable:True
+ ///
+ public decimal? PrcWelf {get;set;}
+
+ ///
+ /// Desc:-
+ /// Default:-
+ /// Nullable:True
+ ///
+ public decimal? PrcProf {get;set;}
+
+ ///
+ /// Desc:-
+ /// Default:-
+ /// Nullable:True
+ ///
+ public decimal? PrcDiff {get;set;}
+
+ ///
+ /// Desc:-
+ /// Default:-
+ /// Nullable:True
+ ///
+ public decimal? PrcGgzl {get;set;}
+
+ ///
+ /// Desc:-
+ /// Default:-
+ /// Nullable:True
+ ///
+ public decimal? PrcMark {get;set;}
+
+ ///
+ /// Desc:-
+ /// Default:-
+ /// Nullable:True
+ ///
+ public decimal? PrcPabl {get;set;}
+
+ ///
+ /// Desc:-
+ /// Default:-
+ /// Nullable:True
+ ///
+ public decimal? PrcPbrh {get;set;}
+
+ ///
+ /// Desc:-
+ /// Default:-
+ /// Nullable:True
+ ///
+ public decimal? PrcBack {get;set;}
+
+ ///
+ /// Desc:-
+ /// Default:-
+ /// Nullable:True
+ ///
+ public int? IsWatsew {get;set;}
+
+ ///
+ /// Desc:-
+ /// Default:-
+ /// Nullable:True
+ ///
+ public string Elecapty {get;set;}
+
+ ///
+ /// Desc:-
+ /// Default:-
+ /// Nullable:True
+ ///
+ public int? IsCenair {get;set;}
+
+ ///
+ /// Desc:-
+ /// Default:-
+ /// Nullable:True
+ ///
+ public int? IsPipgas {get;set;}
+
+ ///
+ /// Desc:-
+ /// Default:-
+ /// Nullable:True
+ ///
+ public string GassUserno {get;set;}
+
+ ///
+ /// Desc:-
+ /// Default:-
+ /// Nullable:True
+ ///
+ public string RentType {get;set;}
+
+ ///
+ /// Desc:-
+ /// Default:-
+ /// Nullable:True
+ ///
+ public string WatAcctName {get;set;}
+
+ ///
+ /// Desc:-
+ /// Default:-
+ /// Nullable:True
+ ///
+ public string WatBankno {get;set;}
+
+ ///
+ /// Desc:-
+ /// Default:-
+ /// Nullable:True
+ ///
+ public string WatAccts {get;set;}
+
+ ///
+ /// Desc:-
+ /// Default:-
+ /// Nullable:True
+ ///
+ public decimal? Flatlayer {get;set;}
+
+ ///
+ /// Desc:-
+ /// Default:-
+ /// Nullable:True
+ ///
+ public string FlatCode {get;set;}
+
+ ///
+ /// Desc:-
+ /// Default:-
+ /// Nullable:True
+ ///
+ public string Acces {get;set;}
+
+ ///
+ /// Desc:-
+ /// Default:-
+ /// Nullable:True
+ ///
+ public string Descs {get;set;}
+
+ ///
+ /// Desc:-
+ /// Default:-
+ /// Nullable:True
+ ///
+ public DateTime? SynDate {get;set;}
+
+ ///
+ /// Desc:-
+ /// Default:-
+ /// Nullable:True
+ ///
+ public DateTime? CreateTime {get;set;}
+
+ ///
+ /// Desc:-
+ /// Default:-
+ /// Nullable:True
+ ///
+ public string CreateUser {get;set;}
+
+ ///
+ /// Desc:-
+ /// Default:-
+ /// Nullable:True
+ ///
+ public DateTime? EditTime {get;set;}
+
+ ///
+ /// Desc:-
+ /// Default:-
+ /// Nullable:True
+ ///
+ public string EditUser {get;set;}
+
+ ///
+ /// Desc:-
+ /// Default:-
+ /// Nullable:True
+ ///
+ public int? IsVaild {get;set;}
+
+ ///
+ /// Desc:-
+ /// Default:-
+ /// Nullable:True
+ ///
+ public int? IsProxy {get;set;}
+
+ ///
+ /// Desc:-
+ /// Default:-
+ /// Nullable:True
+ ///
+ public int? IsBused {get;set;}
+
+ ///
+ /// Desc:-
+ /// Default:-
+ /// Nullable:True
+ ///
+ public int? IsMfee {get;set;}
+
+ ///
+ /// Desc:-
+ /// Default:-
+ /// Nullable:True
+ ///
+ public string MFeeStDate {get;set;}
+
+ ///
+ /// Desc:-
+ /// Default:-
+ /// Nullable:True
+ ///
+ public int? IsFfee {get;set;}
+
+ ///
+ /// Desc:-
+ /// Default:-
+ /// Nullable:True
+ ///
+ public string FFeeStDate {get;set;}
+
+ ///
+ /// Desc:-
+ /// Default:-
+ /// Nullable:True
+ ///
+ public decimal? FeeManage {get;set;}
+
+ ///
+ /// Desc:-
+ /// Default:-
+ /// Nullable:True
+ ///
+ public decimal? FeeFixfund {get;set;}
+
+ ///
+ /// Desc:-
+ /// Default:-
+ /// Nullable:True
+ ///
+ public string ZapProp {get;set;}
+
+ ///
+ /// Desc:-
+ /// Default:-
+ /// Nullable:True
+ ///
+ public string ZapUser {get;set;}
+
+ ///
+ /// Desc:-
+ /// Default:-
+ /// Nullable:True
+ ///
+ public DateTime? ZapTime {get;set;}
+
+ ///
+ /// Desc:-
+ /// Default:-
+ /// Nullable:True
+ ///
+ public DateTime? EndfixTime {get;set;}
+
+ ///
+ /// Desc:-
+ /// Default:-
+ /// Nullable:True
+ ///
+ public string Zfsx {get;set;}
+
+ ///
+ /// Desc:-
+ /// Default:-
+ /// Nullable:True
+ ///
+ public int? IsProprec {get;set;}
+
+ ///
+ /// Desc:-
+ /// Default:-
+ /// Nullable:True
+ ///
+ public string EsriLocationx {get;set;}
+
+ ///
+ /// Desc:-
+ /// Default:-
+ /// Nullable:True
+ ///
+ public string EsriLocationy {get;set;}
+
+ ///
+ /// Desc:-
+ /// Default:-
+ /// Nullable:False
+ ///
+ public string CompanyId {get;set;}
+
+ ///
+ /// Desc:-
+ /// Default:-
+ /// Nullable:False
+ ///
+ public int IsSysData {get;set;}
+
+ ///
+ /// Desc:-
+ /// Default:-
+ /// Nullable:True
+ ///
+ public string Remark {get;set;}
+
+ }
+}
diff --git a/Src/Asp.Net/SqlServerTest/SqlServerTest.csproj b/Src/Asp.Net/SqlServerTest/SqlServerTest.csproj
index 23f749e69..7cb50e568 100644
--- a/Src/Asp.Net/SqlServerTest/SqlServerTest.csproj
+++ b/Src/Asp.Net/SqlServerTest/SqlServerTest.csproj
@@ -47,6 +47,7 @@
+
diff --git a/Src/Asp.Net/SqlServerTest/UnitTest/Query/SingleQuery.cs b/Src/Asp.Net/SqlServerTest/UnitTest/Query/SingleQuery.cs
index c06102a0c..01a872c15 100644
--- a/Src/Asp.Net/SqlServerTest/UnitTest/Query/SingleQuery.cs
+++ b/Src/Asp.Net/SqlServerTest/UnitTest/Query/SingleQuery.cs
@@ -132,6 +132,19 @@ namespace OrmTest.UnitTest
new List() {
new SugarParameter("@Name0","a")
}, t14.Key, t14.Value, "single t14 error ");
+
+
+ var t15 = db.Queryable()
+ .Select(x => new
+ {
+
+ TGYArea = SqlFunc.AggregateSum(SqlFunc.IIF(x.FlatProp == "1", x.Areas, 0))
+ }).ToSql();
+ base.Check("SELECT SUM(( CASE WHEN ( [FlatProp] = @FlatProp0 ) THEN [Areas] ELSE @MethodConst1 END )) AS [TGYArea] FROM [RENT_CAPITAL] ", new List()
+ {
+ new SugarParameter("@FlatProp0","1"),
+ new SugarParameter("@MethodConst1",0)
+ }, t15.Key, t15.Value, "single t15 error");
}
}
}
diff --git a/Src/Asp.Net/SqlSugar/ExpressionsToSql/ResolveItems/MethodCallExpressionResolve.cs b/Src/Asp.Net/SqlSugar/ExpressionsToSql/ResolveItems/MethodCallExpressionResolve.cs
index 1fe6b24b7..a56e5695a 100644
--- a/Src/Asp.Net/SqlSugar/ExpressionsToSql/ResolveItems/MethodCallExpressionResolve.cs
+++ b/Src/Asp.Net/SqlSugar/ExpressionsToSql/ResolveItems/MethodCallExpressionResolve.cs
@@ -231,7 +231,11 @@ namespace SqlSugar
{
foreach (var item in args)
{
- AppendItem(parameter, name, args, model, item);
+ var expItem = item;
+ if (item is UnaryExpression) {
+ expItem = (item as UnaryExpression).Operand;
+ }
+ AppendItem(parameter, name, args, model, expItem);
}
if (appendArgs != null)
{