zoukankan      html  css  js  c++  java
  • Linq 学习

    查询表达式:

    1常用的Linq字句:from(要查找的数据源),select(指定查询要返回的目标数据),where(指定查询的筛选条件),orderby(升序倒叙),group(指定元素的分组字段),Join(指定多个数据源的关联方式)

    1.1:from字句:from localval in dataSource

    var query = from intval in array select intval+1;
               foreach (int val in query)
                 {
                     Console.WriteLine("{0}", val);
                 }
                 Console.ReadLine();

    1.2:select字句:from localval in dataSource select expression

    expression是一个表达式,用来计算要作为查询结果的元素

    //用数据源中所有的元素创建一个匿名类型
                var query = from intval in array select new {Intval=intval,Doublevalue=intval*1.5 };
                foreach (var item in query)
                 {
                     Console.WriteLine(item);
                 }
                 Console.ReadLine();

    1.3 where字句:from localval in dataSource where condition select expression

    //用数据源中所有的元素创建一个匿名类型
                var query = from intval in array where (intval>30&&intval<80)select new {Intval=intval,Doublevalue=intval*1.5 };
                foreach (var item in query)
                 {
                     Console.WriteLine(item);
                 }
                 Console.ReadLine();

    where intval>30 where intval<80==where (intval>30&&intval<80)

    1.4:orderby 字句:orderby expression [sortType]

    expression 是要进行排序的表达式,可以是from字句中的localval。sortType是可选参数(ascending 升序)(desending 降序)

     var query = from intval in array  orderby intval descending select new {Intval=intval,Doublevalue=intval*1.5 };
                foreach (var item in query)
                 {
                     Console.WriteLine(item);
                 }
                 Console.ReadLine();

  • 相关阅读:
    【转】PHP error_reporting() 错误控制函数功能详解
    第八讲_图像问答Image Question Answering
    C中的继承和多态
    第七讲_图像描述(图说)Image Captioning
    TensorFlow 之 高层封装slim,tflearn,keras
    第六讲_图像分割Image Segmentation
    第五讲_图像识别之图像检测Image Detection
    Tensorflow 之 TensorBoard可视化Graph和Embeddings
    第四讲_图像识别之图像分类Image Classification
    理解Neural Style
  • 原文地址:https://www.cnblogs.com/zhang123/p/3394307.html
Copyright © 2011-2022 走看看