@@ -555,7 +555,7 @@ static void Main(string[] args)
555555 var fsql = new FreeSql . FreeSqlBuilder ( )
556556 . UseAutoSyncStructure ( true )
557557 . UseNoneCommandParameter ( true )
558- . UseNameConvert ( NameConvertType . ToLower )
558+ // .UseNameConvert(NameConvertType.ToLower)
559559 //.UseMappingPriority(MappingPriorityType.Attribute, MappingPriorityType.FluentApi, MappingPriorityType.Aop)
560560 . UseAdoConnectionPool ( true )
561561
@@ -596,7 +596,7 @@ static void Main(string[] args)
596596 //.UseConnectionString(DataType.QuestDb, "host=localhost;port=8812;username=admin;password=quest;database=qdb;ServerCompatibilityMode=NoTypeLoading;")
597597
598598 //.UseConnectionString(DataType.ClickHouse, "DataCompress=False;BufferSize=32768;SocketTimeout=10000;CheckCompressedHash=False;Encrypt=False;Compressor=lz4;Host=192.168.0.121;Port=8125;Database=PersonnelLocation;Username=root;Password=123")
599- . UseConnectionFactory ( DataType . ClickHouse , ( ) => null )
599+ // .UseConnectionFactory(DataType.ClickHouse, () => null)
600600 . UseMonitorCommand ( cmd =>
601601 {
602602 Console . WriteLine ( cmd . CommandText + "\r \n " ) ;
@@ -608,16 +608,55 @@ static void Main(string[] args)
608608 . UseGenerateCommandParameterWithLambda ( true )
609609 . Build ( ) ;
610610 BaseEntity . Initialization ( fsql , ( ) => _asyncUow . Value ) ;
611- #endregion
612-
613- var clickhouseSql1 = fsql . Select < User1 > ( ) . Where ( a => new [ ] { 1 , 2 , 3 } . Contains ( a . GroupId ) ) . ToSql ( ) ;
614- var clickhouseVal1 = new [ ] { 1 , 2 , 3 } ;
615- var clickhouseSql2 = fsql . Select < User1 > ( ) . Where ( a => clickhouseVal1 . Contains ( a . GroupId ) ) . ToSql ( ) ;
616- var clickhouseSql3 = fsql . Select < User1 > ( ) . Where ( a => a . Tags . Contains ( "tag1" ) ) . ToSql ( ) ;
617- var clickhouseVal2 = "tag2" ;
618- var clickhouseSql4 = fsql . Select < User1 > ( ) . Where ( a => a . Tags . Contains ( clickhouseVal2 ) ) . ToSql ( ) ;
611+ #endregion
612+
613+
614+ var list111222 = fsql . Select < OrderLine , Product > ( )
615+ . InnerJoin ( ( l , p ) => l . ProductId == p . ID )
616+ . GroupBy ( ( l , p ) => new { p . ID , ShopType = l . ShopType ?? 0 } )
617+ . WithTempQuery ( a => new
618+ {
619+ a . Key . ID ,
620+ Money = a . Sum ( a . Value . Item1 . Amount ) * a . Key . ShopType
621+ } )
622+ . ToList ( ) ;
623+ Console . WriteLine ( list111222 ) ;
624+
625+ var list0x1sql = fsql . Select < OrderLine22x , Product22x > ( )
626+ . InnerJoin ( ( l , p ) => l . ProductId == p . ID )
627+ . GroupBy ( ( l , p ) => new { p . ID , l . ShopType } )
628+ . WithTempQuery ( a => new {
629+ a . Key . ID ,
630+ Money2 = a . Key . ShopType ,
631+ Money = a . Key . ShopType == 1 ? a . Value . Item1 . Price * a . Value . Item1 . Amount : a . Value . Item1 . Price * a . Value . Item1 . Amount * 1.1m
632+ } )
633+ . ToSql ( ) ;
634+ Console . WriteLine ( list0x1sql ) ;
635+ var sql1c2 = fsql . Select < User1 > ( )
636+ . GroupBy ( a => new { a . Nickname , a . Avatar } )
637+ . WithTempQuery ( b => new
638+ {
639+ sum = b . Sum ( b . Value . Sort ) ,
640+ b . Key . Nickname ,
641+ b . Key . Avatar ,
642+ } )
643+ . OrderByDescending ( arg => arg . sum )
644+ . ToSql ( arg => new
645+ {
646+ str1 = string . Concat ( arg . Nickname , '-' , arg . Avatar , '-' ) ,
647+ str2 = string . Concat ( arg . Nickname , '-' , arg . Avatar )
648+ } ) ; //报错 多括号
649+ //.ToOne(arg => string.Concat(arg.Nickname, '-', arg.Avatar)); //正常
650+ Console . WriteLine ( sql1c2 ) ;
651+
652+ //var clickhouseSql1 = fsql.Select<User1>().Where(a => new[] { 1, 2, 3 }.Contains(a.GroupId)).ToSql();
653+ // var clickhouseVal1 = new[] { 1, 2, 3 };
654+ // var clickhouseSql2 = fsql.Select<User1>().Where(a => clickhouseVal1.Contains(a.GroupId)).ToSql();
655+ // var clickhouseSql3 = fsql.Select<User1>().Where(a => a.Tags.Contains("tag1")).ToSql();
656+ // var clickhouseVal2 = "tag2";
657+ // var clickhouseSql4 = fsql.Select<User1>().Where(a => a.Tags.Contains(clickhouseVal2)).ToSql();
619658
620- fsql . Update < User1 > ( )
659+ fsql . Update < User1 > ( )
621660 . Where ( t => t . GroupId == 1 )
622661 . ExecuteUpdated ( ) ;
623662
@@ -831,16 +870,6 @@ static void Main(string[] args)
831870 fsql . UseJsonMap ( ) ;
832871 fsql . Select < MiDevice > ( ) . Where ( a => a . FormLocking == null ) . Count ( ) ;
833872
834- var list0x1sql = fsql . Select < OrderLine22x , Product22x > ( )
835- . InnerJoin ( ( l , p ) => l . ProductId == p . ID )
836- . GroupBy ( ( l , p ) => new { p . ID , l . ShopType } )
837- . WithTempQuery ( a => new {
838- a . Key . ID ,
839- Money2 = a . Key . ShopType ,
840- Money = a . Key . ShopType == 1 ? a . Value . Item1 . Price * a . Value . Item1 . Amount : a . Value . Item1 . Price * a . Value . Item1 . Amount * 1.1m
841- } )
842- . ToSql ( ) ;
843- Console . WriteLine ( list0x1sql ) ;
844873
845874 fsql . Delete < TypeHandler01 > ( ) . Where ( "1=1" ) . ExecuteAffrows ( ) ;
846875 FreeSql . Internal . Utils . TypeHandlers . TryAdd ( typeof ( TestIdAndIdentity ) , new String_TestIdAndIdentity ( ) ) ;
@@ -1211,22 +1240,8 @@ static void Main(string[] args)
12111240 . Set ( ( a , b ) => a . Nickname == "b.groupname" )
12121241 . ExecuteAffrows ( ) ;
12131242
1214- var sql1c2 = fsql . Select < User1 > ( )
1215- . GroupBy ( a => new { a . Nickname , a . Avatar } )
1216- . WithTempQuery ( b => new
1217- {
1218- sum = b . Sum ( b . Value . Sort ) ,
1219- b . Key . Nickname ,
1220- b . Key . Avatar ,
1221- } )
1222- . OrderByDescending ( arg => arg . sum )
1223- . ToSql ( arg => new
1224- {
1225- str1 = string . Concat ( arg . Nickname , '-' , arg . Avatar , '-' ) ,
1226- str2 = string . Concat ( arg . Nickname , '-' , arg . Avatar )
1227- } ) ; //报错 多括号
1228- //.ToOne(arg => string.Concat(arg.Nickname, '-', arg.Avatar)); //正常
1229- Console . WriteLine ( sql1c2 ) ;
1243+
1244+
12301245
12311246 var xp = new Xpb ( )
12321247 {
@@ -3065,4 +3080,26 @@ public class Test2
30653080 public string ItemName { get ; set ; }
30663081
30673082 public bool IsEnabled { get ; set ; }
3068- }
3083+ }
3084+ [ JsonObject ( MemberSerialization . OptIn ) , Table ( Name = "T_OrderLine111222" ) ]
3085+ public partial class OrderLine
3086+ {
3087+
3088+ public string Id { get ; set ; }
3089+ public string OrderId { get ; set ; }
3090+
3091+ public string ShopId { get ; set ; }
3092+ [ JsonProperty , Column ( Name = "Shop_Type" ) ]
3093+ public int ? ShopType { get ; set ; }
3094+ public string ProductId { get ; set ; }
3095+ public decimal Price { get ; set ; }
3096+ public decimal ? Amount { get ; set ; }
3097+ }
3098+ [ JsonObject ( MemberSerialization . OptIn ) , Table ( Name = "T_Product111222" ) ]
3099+ public partial class Product
3100+ {
3101+ public string ID { get ; set ; }
3102+ public string Name { get ; set ; }
3103+ public string Model { get ; set ; }
3104+ }
3105+
0 commit comments