@@ -663,6 +663,82 @@ private string ConvertMethodCallToSql(MethodCallExpression methodCallExpression,
663
663
string valueSql = ExpressionToSql ( methodCall . Arguments [ 0 ] , rowExpression ) ;
664
664
return $ "atan({ valueSql } )";
665
665
} ,
666
+
667
+ // int.ToString()
668
+ [ typeof ( int ) . GetMethod ( nameof ( int . ToString ) , [ ] ) ! ] = ( methodCall , rowExpression ) => {
669
+ string intSql = ExpressionToSql ( methodCall . Object ! , rowExpression ) ;
670
+ return $ "cast({ intSql } as text)";
671
+ } ,
672
+
673
+ // int.Parse(string)
674
+ [ typeof ( int ) . GetMethod ( nameof ( int . Parse ) , [ typeof ( string ) ] ) ! ] = ( methodCall , rowExpression ) => {
675
+ string strSql = ExpressionToSql ( methodCall . Arguments [ 0 ] , rowExpression ) ;
676
+ return $ "cast({ strSql } as integer)";
677
+ } ,
678
+
679
+ // int.Equals(int)
680
+ [ typeof ( int ) . GetMethod ( nameof ( int . Equals ) , [ typeof ( int ) ] ) ! ] = ( methodCall , rowExpression ) => {
681
+ string int1Sql = ExpressionToSql ( methodCall . Object ! , rowExpression ) ;
682
+ string int2Sql = ExpressionToSql ( methodCall . Arguments [ 0 ] , rowExpression ) ;
683
+ return $ "{ int1Sql } = { int2Sql } ";
684
+ } ,
685
+
686
+ // long.ToString()
687
+ [ typeof ( long ) . GetMethod ( nameof ( long . ToString ) , [ ] ) ! ] = ( methodCall , rowExpression ) => {
688
+ string longSql = ExpressionToSql ( methodCall . Object ! , rowExpression ) ;
689
+ return $ "cast({ longSql } as text)";
690
+ } ,
691
+
692
+ // long.Parse(string)
693
+ [ typeof ( long ) . GetMethod ( nameof ( long . Parse ) , [ typeof ( string ) ] ) ! ] = ( methodCall , rowExpression ) => {
694
+ string strSql = ExpressionToSql ( methodCall . Arguments [ 0 ] , rowExpression ) ;
695
+ return $ "cast({ strSql } as integer)";
696
+ } ,
697
+
698
+ // long.Equals(long)
699
+ [ typeof ( long ) . GetMethod ( nameof ( long . Equals ) , [ typeof ( long ) ] ) ! ] = ( methodCall , rowExpression ) => {
700
+ string long1Sql = ExpressionToSql ( methodCall . Object ! , rowExpression ) ;
701
+ string long2Sql = ExpressionToSql ( methodCall . Arguments [ 0 ] , rowExpression ) ;
702
+ return $ "{ long1Sql } = { long2Sql } ";
703
+ } ,
704
+
705
+ // float.ToString()
706
+ [ typeof ( float ) . GetMethod ( nameof ( float . ToString ) , [ ] ) ! ] = ( methodCall , rowExpression ) => {
707
+ string floatSql = ExpressionToSql ( methodCall . Object ! , rowExpression ) ;
708
+ return $ "cast({ floatSql } as text)";
709
+ } ,
710
+
711
+ // float.Parse(string)
712
+ [ typeof ( float ) . GetMethod ( nameof ( float . Parse ) , [ typeof ( string ) ] ) ! ] = ( methodCall , rowExpression ) => {
713
+ string strSql = ExpressionToSql ( methodCall . Arguments [ 0 ] , rowExpression ) ;
714
+ return $ "cast({ strSql } as integer)";
715
+ } ,
716
+
717
+ // float.Equals(float)
718
+ [ typeof ( float ) . GetMethod ( nameof ( float . Equals ) , [ typeof ( float ) ] ) ! ] = ( methodCall , rowExpression ) => {
719
+ string float1Sql = ExpressionToSql ( methodCall . Object ! , rowExpression ) ;
720
+ string float2Sql = ExpressionToSql ( methodCall . Arguments [ 0 ] , rowExpression ) ;
721
+ return $ "{ float1Sql } = { float2Sql } ";
722
+ } ,
723
+
724
+ // double.ToString()
725
+ [ typeof ( double ) . GetMethod ( nameof ( double . ToString ) , [ ] ) ! ] = ( methodCall , rowExpression ) => {
726
+ string doubleSql = ExpressionToSql ( methodCall . Object ! , rowExpression ) ;
727
+ return $ "cast({ doubleSql } as text)";
728
+ } ,
729
+
730
+ // double.Parse(string)
731
+ [ typeof ( double ) . GetMethod ( nameof ( double . Parse ) , [ typeof ( string ) ] ) ! ] = ( methodCall , rowExpression ) => {
732
+ string doubleSql = ExpressionToSql ( methodCall . Arguments [ 0 ] , rowExpression ) ;
733
+ return $ "cast({ doubleSql } as integer)";
734
+ } ,
735
+
736
+ // double.Equals(double)
737
+ [ typeof ( double ) . GetMethod ( nameof ( double . Equals ) , [ typeof ( double ) ] ) ! ] = ( methodCall , rowExpression ) => {
738
+ string double1Sql = ExpressionToSql ( methodCall . Object ! , rowExpression ) ;
739
+ string double2Sql = ExpressionToSql ( methodCall . Arguments [ 0 ] , rowExpression ) ;
740
+ return $ "{ double1Sql } = { double2Sql } ";
741
+ } ,
666
742
} ;
667
743
private Dictionary < MemberInfo , Func < MemberExpression , ParameterExpression , string > > GetDefaultMemberToSqlConverters ( ) => new ( ) {
668
744
// string.Length
0 commit comments