zoukankan      html  css  js  c++  java
  • Bitter.Core系列 十二 :Bitter ORM NETCORE ORM 全网最粗暴简单易用高性能的 NETCore 之 支持的 where 条件表达式

    Bitter.Core 内置了支持大部分的 linq 的条件表达式。基本上符合我们 where 条件所需。Bitter.Core 的支持 表达式内置  扩展 有:

    • EndsWith    在Sql 解析成:  ‘%s’
    • StartsWith   在Sql 解析成:  ‘s%’
    • Contains     在Sql 解析成:  ‘%s%’
    • In                在Sql 解析成:     IN (1,2,34)
    • NotIn          在Sql 解析成:   NOT IN  (1,2,34)
    • IsNull          在Sql 解析成:    ISNUL(dbfiled,0)
    • Like             在Sql 解析成:    Like‘%s%’
    • NotLike       在Sql 解析成:   Not Like‘%s%’
    • >=              在Sql 解析成:   >=
    • <=              在Sql 解析成:   <=   
    • >                 在Sql 解析成:   >
    • <                 在Sql 解析成:   <
    • =                 在Sql 解析成:   =
    • !=                在Sql 解析成:   !=
    • &&              在Sql 解析成:  and (….)
    • ||                 在Sql 解析成:  (….) || (…)


    下面附上条件表达式如下demo 所示:


    static void Main(string[] args)
            {
                Console.WriteLine("Hello World!");
    
                MonitorInfo monitor_end = db.FindQuery<TStudentInfo>().Where(p => p.FName.EndsWith("h")).ToMonitorInfo();
    
                MonitorInfo monitor_start = db.FindQuery<TStudentInfo>().Where(p => p.FName.StartsWith("j")).ToMonitorInfo();
    
                MonitorInfo monitor_contains = db.FindQuery<TStudentInfo>().Where(p => p.FName.Contains("h")).ToMonitorInfo();
    
                MonitorInfo monitor_in = db.FindQuery<TStudentInfo>().Where(p => p.FAage.In(new int?[] { 1,2,3,4})).ToMonitorInfo();
    
                MonitorInfo monitor_notin = db.FindQuery<TStudentInfo>().Where(p => p.FAage.NotIn(new int?[] { 1, 2, 3, 4 })).ToMonitorInfo();
    
                MonitorInfo monitor_isnull_str = db.FindQuery<TStudentInfo>().Where(p => p.FName.IsNull("")).ToMonitorInfo();
    
                MonitorInfo monitor_isnull_int = db.FindQuery<TStudentInfo>().Where(p => p.FAage.IsNull(-1)).ToMonitorInfo();
    
                MonitorInfo monitor_like = db.FindQuery<TStudentInfo>().Where(p => p.FName.Like("h")).ToMonitorInfo();
    
                MonitorInfo monitor_Notlike = db.FindQuery<TStudentInfo>().Where(p => p.FName.NotLike("h")).ToMonitorInfo();
    
                MonitorInfo monitor_ThanEquel = db.FindQuery<TStudentInfo>().Where(p => p.FAage>=10).ToMonitorInfo();
    
                MonitorInfo monitor_LessThanEquel = db.FindQuery<TStudentInfo>().Where(p => p.FAage <=10).ToMonitorInfo();
    
                MonitorInfo monitor_And = db.FindQuery<TStudentInfo>().Where(p => p.FAage <= 10 && p.FAage<=20).ToMonitorInfo();
    
                MonitorInfo monitor_And_And = db.FindQuery<TStudentInfo>().Where(p =>p.FName.Like("h")&&(p.FAage <= 10 && p.FAage <= 20)).ToMonitorInfo();
    
                MonitorInfo monitor_And_And_And = db.FindQuery<TStudentInfo>().Where(p => p.FName.Like("h") && (p.FAage <= 10 && p.FAage <= 20)).Where(p=>p.FAddTime>"2020-10-11".ToSafeDateTime()).ToMonitorInfo();
    
                var k= Console.ReadKey();
            }
  • 相关阅读:
    [React Native] Target both iPhone and iPad with React Native
    [Angular] Increasing Performance by using Pipe
    [Angular] Angular CDK Intro
    [React] Refactor componentWillReceiveProps() to getDerivedStateFromProps() in React 16.3
    [Python] Create a minimal website in Python using the Flask Microframework
    [GraphQL] Apollo React Mutation Component
    [Angular] Introduce to NGXS
    《火球——UML大战需求分析》(第2章 耗尽脑汁的需求分析工作)——2.4 UML助力需求分析
    《火球——UML大战需求分析》(第2章 耗尽脑汁的需求分析工作)——2.5 小结与练习
    [Django实战] 第4篇
  • 原文地址:https://www.cnblogs.com/davidchildblog/p/14329100.html
Copyright © 2011-2022 走看看