zoukankan      html  css  js  c++  java
  • .net Linq

    今天取数据,遇到麻烦事儿,不想懂后台程序,只能用Linq,但是只听过没用过,经过简单的入门,终于实现了我想要的效果。

    获取集合升序中除了最后一条其他的数据,因为我需要最后一条排序是最新的数据,其他的是历史数据,在这里我需要历史数据!

    IList<PsychConPlanInfo> pslst = IMPCP.GetList(psinfo, 5, 1).OrderBy(i => i.CreateTime).ToList();
    int count = pslst.Count();
    var query = (from o in pslst orderby o.CreateTime ascending select o).Take(count-1).ToList();

    用到Linq Take()。取数据前几条,还有一个是Skip()去数据后几条。

    在网上搜索很多相关用法,只说在(from o in pslst orderby o.CreateTime ascending select o)查询后面加上Take().结果没有值。又琢磨了半天才发现需要转为集合ToList()才可以!

    随笔!

  • 相关阅读:
    hdfs command
    开机启动
    date
    tabulate
    django前后端分离403 csrf token missing or incorrect
    设计一个程序,程序中有三个类,Triangle,Lader,Circle。
    总结,
    数据库2
    JDBC数据库1
    网络编程2
  • 原文地址:https://www.cnblogs.com/zjmzone/p/2354578.html
Copyright © 2011-2022 走看看