Once again, in this series of posts I look at the parts of the .NET Framework that may seem trivial, but can help improve your code by making it easier to write and maintain. The index of all my past little wonders posts can be found here. We've seen…
实体类: public class ReportEntity { public string FactorName { get; set; } public double MaxVal { get; set; } public double MinVal { get; set; } public double AvgVal { get; set; } public string UpdateTime { get; set; } public string Unit { get; set; } p…
ROW_NUMBER() OVER (ORDER BY (select Null)) AS Id entity framework 查询中有这句会有异常…
转换数据类型      转换方法更改输入对象的类型.      LINQ 查询中的转换运算可用于各种应用程序.下面是一些示例: Enumerable.AsEnumerable<TSource> 方法可用于隐藏类型的标准查询运算符的自定义实现. Enumerable.OfType<TResult> 方法可用于启用非参数化集合以进行 LINQ 查询. Enumerable.ToArray<TSource> .Enumerable.ToDictionary.Enumerabl…
5.4 LINQ查询运算符 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Collections; using System.IO; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { List<Person> list = new…
1.IEnumerable的作用 在使用Linq查询数据时经常以IEnumerable<T>来作为数据查询返回对象,在使用foreach进行遍历时需要该对象实现IEnumerable接口,这2个功能让我对IEnumerable充满了无穷的好奇.然而在VS中查看IEnumerable的定义时发现它只定义了一个GetEnumerator()方法,关于IEnumerator我知道它依靠MoveNext和Current来达到Foreach的遍历,但是具体是如何将数据进行迭代的,完整的流程是怎样的?这些…
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Services.Description; using System.Web.Services.Protocols; using System.Web.Services.Discovery; using System.Web.Services; using System.Net; using S…
1.首先我们应该知道什么是扩展方法: 扩展方法使您能够向现有类型“添加”方法,而无需创建新的派生类型.重新编译或以其他方式修改原始类型. 扩展方法是一种特殊的静态方法,但可以像扩展类型上的实例方法一样进行调用. 2.知道了扩展方法怎么创建呢? 定义一个静态类以包含扩展方法.  将该扩展方法实现为静态方法,并使其至少具有与包含类相同的可见性. 该方法的第一个参数指定方法所操作的类型:该参数必须以 this 修饰符开头. 在调用代码中,添加一条 using 指令以指定包含扩展方法类的 命名空间. 按…
首先先来扯一下,这篇博文是我第一次写的,主要是我的一些摘录,希望对大家有所帮助. Linq的基础 •LINQ(读音link):Linq To SQL(过时).Linq To Object.Linq To XML.Linq To entity,目的:以统一的方式对数据进行操作.看起来非常像SQL语句,但是和SQL无关. •var关键字,var类型用来简化类型的声明,var i = 2,并不说明i是无类型的,编译器会自动根据右边的值推断(这叫类型推断)var代表的值.var只能用来语句中,不能用在返…
C#基础之IEnumerable 1.IEnumerable的作用 在使用Linq查询数据时经常以IEnumerable<T>来作为数据查询返回对象,在使用foreach进行遍历时需要该对象实现IEnumerable接口,这2个功能让我对IEnumerable充满了无穷的好奇.然而在VS中查看IEnumerable的定义时发现它只定义了一个GetEnumerator()方法,关于IEnumerator我知道它依靠MoveNext和Current来达到Foreach的遍历,但是具体是如何将数据进…