对于初学者步骤,使用Linqpad非常基本的运行LINQ到SQL查询 [英] Steps for a beginner to run very basic linq to sql query using Linqpad

查看:330
本文介绍了对于初学者步骤,使用Linqpad非常基本的运行LINQ到SQL查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试使用 LinqPad 和如何开始它得到frustated学习LINQ的。比方说,我想写一个C#表达和C#说明书,我有一个名为产品在SQL Server中的表,我想拉所有行的价格是大于50哟会怎么写呢?


解决方案

比方说,我想写一个C#表达和C#说明书,我
在SQL服务器上有一个表命名产品,我想拉的所有行
,其中价格是大于50哟会怎么写呢?




LINQPad自动生成的类型的DataContext给你,所以你不需要任何实例。在C#中的表达模式,只需键入如下因素:

  Products.Where(P => p.Price→50)

和按F5。或者,你可能更愿意使用一个查询表达式:

 从产品
p其中p.Price> 50
的选择P

在C#中的语句模式,你需要调用转储( )方法来告诉它写出来的结果。您还需要终止与分号表达式:

  Products.Where(P => p.Price> 50)使用.dump(); 

有在LINQPad的样品部分更多的例子 - 看5分钟的诱导


Trying to learn Linq using LinqPad and getting frustated with how to start on it. Let's say I want to write a C# Expression and a C# statment where I have a table in SQL server named Products and I want to pull all rows where price is greater then 50. How would yo write it?

解决方案

Let's say I want to write a C# Expression and a C# statment where I have a table in SQL server named Products and I want to pull all rows where price is greater then 50. How would yo write it?

LINQPad builds the typed DataContext for you automatically, so you don't need to instantiate anything. In C# expression mode, just type the folowing:

Products.Where(p => p.Price > 50)

and press F5. Alternatively, you might prefer to use a query expression:

from p in Products
where p.Price > 50
select p

In C# statements mode, you'll need to call the Dump() method to tell it to write out the results. You'll also need to terminate the expression with a semicolon:

Products.Where(p => p.Price > 50).Dump();

There are more examples in the samples section of LINQPad - look at the 5-minute induction.

这篇关于对于初学者步骤,使用Linqpad非常基本的运行LINQ到SQL查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆