SQL 语句有很多函数如len(),now()等等。如何来生成这些函数。最近研究也写办法共大家参考。

      一.首先建立一个建一个扩展类,控制只能允许这些函数出现,如果出现其他函数就直接报异常。

 1  public static class SQLMethods
 2     {
 3         public static bool DB_In<T>(this T t, List<T> list)  // in
 4         {
 5             return true;
 6         }
 7         public static Boolean DB_NotIn<T>(this T t, List<T> list) // not in
 8         {
 9             return true;
10         }
11         public static int DB_Length(this string t)  // len();
12         {
13             return 0;
14         }
15         public static bool DB_Like(this string t, string str) // like
16         {
17             return true;
18         }
19         public static bool DB_NotLike(this string t, string str) // not like 
20         {
21             return true;
22         }
23     }
View Code

相关文章:

  • 2022-12-23
  • 2021-06-17
  • 2021-12-26
  • 2021-12-13
  • 2021-11-11
  • 2021-10-25
猜你喜欢
  • 2021-11-15
  • 2022-02-08
  • 2022-12-23
  • 2022-03-08
  • 2021-11-19
  • 2022-12-23
相关资源
相似解决方案