• Linq


    //Linq:language Intergarted Query 语言整合查询
                //select * from tb_name
                //条件必须实现IEnumerable接口
                //Linq to SQL,Linq to Xml ,Linq to DataSet,Linq to Objects
                int[] numbers = { 5, 10, 8, 3, 6, 12 };
                //Query Systax
                var numQuery1 = from num in numbers
                                where num % 2 == 0
                                orderby num
                                select num;
                foreach (int num in numQuery1)
                {
                    Console.WriteLine(num);
                }
                //method Systax
                var numQuery2 = numbers.Where(n => n % 2 == 0).OrderBy(n => n);
                foreach (int num in numQuery2)
                {
                    Console.WriteLine(num);
                }
                Console.ReadLine();

    语法

            private static void QuerySysnax()
            {
                //1.datasource
                double[] numbers = { 110.00, 1, 2, 3, 4, 5, 6, 7 };
                //2.query creation
                var numquery = from num in numbers
                               where num % 2 == 0
                               select num;
                int numCount = numquery.Count();
                //3.query execution
                Console.WriteLine("1234567890");
                foreach (double num in numquery)
                {
                    Console.WriteLine("{0,10}", num);
                }
            }

    基本操作

    from 获取数据源

    where 过滤条件

    order 排序

    select 获取结果

    group 

    group into打包(group 一起用)

    join 

    let 中间变量

    private static void myquery()
            {
                string[] mystrings = { "Hello qxw.", "This is Friday!", "Are you Happy?" };
                var stringQuery = from s in mystrings
                                  let words = s.Split(' ')
                                  from word in words
                                  let w = word.ToUpper()
                                  select w;
                //var stringQuery = from s in mystrings
                //                  let w = s.ToUpper()
                //                  select w;
                foreach (var s in stringQuery)
                {
                    Console.Write("{0} ", s);
                }
            }
  • 相关阅读:
    ConcurrentSkipListMap 源码分析
    ConcurrentHashMap 源码分析
    CopyOnWriteArrayList 源码分析
    AtomicBoolean 源码分析
    commons-lang3-3.4.jar
    Effective Java
    FindBugs Bug Descriptions
    EasyMock
    Apache Maven 入门
    Eclipse
  • 原文地址:https://www.cnblogs.com/handsomer/p/4560985.html
Copyright © 2020-2023  润新知