using System;
using System.Linq; namespace Linq101
{
class Restriction
{
/// <summary>
/// This sample uses where to find all elements of an array less than 5.
/// </summary>
public void Linq1()
{
int[] numbers = { , , , , , , , , , }; var query = from n in numbers
where n <
select n; Console.WriteLine("Numbers < 5 :");
foreach (var number in query)
{
Console.WriteLine(number);
}
} /// <summary>
/// This sample uses where to find all products that are out of stock.
/// </summary>
public void Linq2()
{
var productList = Data.GetProductList(); var query = from product in productList
where product.UnitsInStock ==
select product; Console.WriteLine("Sold out products:");
foreach (var product in query)
{
Console.WriteLine("{0} is sold out!", product.ProductName);
}
} /// <summary>
/// This sample uses where to find all products that are in stock and cost more than 3.00 per unit.
/// </summary>
public void Linq3()
{
var productList = Data.GetProductList(); var query = from product in productList
where product.UnitsInStock > && product.UnitPrice > 3.00M
select product; Console.WriteLine("In-stock products that cost more than 3.00:");
foreach (var product in query)
{
Console.WriteLine("{0} is in stock and cost more than 3.00", product.ProductName);
}
} /// <summary>
/// This sample uses where to find all customers in Washington and then uses the resulting sequence to drill down into their orders.
/// </summary>
public void Linq4()
{
var customerList = Data.GetCustomerList(); var query = from customer in customerList
where customer.Region == "WA"
select customer; Console.WriteLine("Cutomers from Washington and their orders:");
foreach (var customer in query)
{
Console.WriteLine("Customer {0}:{1}", customer.CustomerID, customer.CompanyName);
foreach (var order in customer.Orders)
{
Console.WriteLine(" Order {0}:{1}", order.OrderID, order.OrderDate);
}
}
} /// <summary>
/// This sample demonstrates an indexed Where clause that returns digits whose name is shorter than their value.
/// </summary>
public void Linq5()
{
string[] digits = { "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine" }; var query = digits.Where((digit, index) => digit.Length < index); Console.WriteLine("Short digits:");
foreach (var digit in query)
{
Console.WriteLine("The word {0} is shorter than its value.", digit);
}
}
}
}

Linq101-Restriction的更多相关文章

  1. 关于Access restriction: The type 'Application' is not API (restriction on required library)

    原文链接:http://rxxluowei.iteye.com/blog/671893 今天写第一次写JavaFX的入门程序就GG 遇到了导入API的问题,无奈疯狂地通过网络找解决方案.. 我的问题是 ...

  2. TNS-12540: TNS:internal limit restriction exceeded

    应用程序以及客户端工具(Toad.PL/SQL Developer等)出现突然连接不上数据库服务器的情况,监听日志listener.log里面出现了TSN-12518与TSN-12540错误,如下所示 ...

  3. The constructor BASE64Encoder() is not accessible due to restriction on required library

    在Eclipse中编写Java代码时,用到了BASE64Decoder,import sun.misc.BASE64Decoder;可是Eclipse提示:Access restriction : T ...

  4. Access restriction: The type TaskTopicResolver is not accessible due to restrict

    Access restriction: The type TaskTopicResolver is not accessible due to restrict :  Eclipse 默认把这些受访问 ...

  5. Eclipse 关于“The type * is not accessible due to restriction on required library”问题的解决办法

    The type * is not accessible due to restriction on required library”的错误, 意思是所需要的类库由于受限制无法访问. 解决办法: 1 ...

  6. Access restriction错误解决办法

    Access restriction错误, XX方法 is not accessible due to restriction on required library XXlib 解决方案: Ecli ...

  7. Access restriction: The type 'BASE64Encoder' is not API

    问题的原因好像是这个方法不是安全的,所以不推荐使用,我是在做毕设时要用到的所以就直接用了(毕设要求没有那么严格的要求)

  8. PHPExcel中open_basedir restriction in effect的解决方法

    用PHPExcel做导出execl的时候发现在本地没有问题,但是把网站传到租用的服务器的时候就报错,具体如下: Warning: realpath() [function.realpath]: ope ...

  9. The constructor BASE64Encoder() is not accessible due to restriction on required

    在Eclipse中编写Java代码时,用到了BASE64Decoder,import sun.misc.BASE64Decoder;可是Eclipse提示: Access restriction : ...

  10. Eclipse 编译错误 Access restriction:The type *** is not accessible due to restriction on... 解决方案

    报错: Access restriction:The type JPEGCodec is not accessible due to restriction on required library C ...

随机推荐

  1. 【Java】Java Socket编程(1)基本的术语和概念

    计算机程序能够相互联网,相互通讯,这使一切都成为可能,这也是当今互联网存在的基础.那么程序是如何通过网络相互通信的呢?这就是我记录这系列的笔记的原因.Java语言从一开始就是为了互联网而设计的,它为实 ...

  2. Rundeck,RUN起来!!

    零晨一点, 还好,跑起来了.. 满满的英文文档,肿么办?? 拿下!

  3. c# 类;一维数组;二维数组

    1. 输入邮箱帐号,判断格式是否正确  (1)有且只有一个@          Contains IndexOf ==LastIndexOf  (2)不能以@开头           StartsWi ...

  4. iOS应用架构浅谈

    (整理至http://www.cocoachina.com/ios/20150414/11557.html) 缘由 从事iOS工作一年多了,主要从事QQ钱包SDK开发和财付通app维护,随着对业务的慢 ...

  5. Entity Framwork db First 中 Model验证解决办法。

    由于项目中用到 Entity Framwork db First     每次从数据库生成数据模型之后都会把模型更新. 只要有一个表更新.所有的类都会重新生成. 在网上找了各种例子都是差不多的, 可能 ...

  6. 《A First Course in Probability》-chaper8-极限定理-各类不等式

    詹森不等式: 证明:

  7. poj 1556 The door

    题目链接:http://poj.org/problem?id=1556 #include<cstdio> #include<cstring> #include<cmath ...

  8. poj1019

    有一个序列 1 12 123 1234 ..... ........ ........... 12345678910 ................................ 求第n个数字是什 ...

  9. crossfire 346# B

    Vasya has the square chessboard of size n × n and m rooks. Initially the chessboard is empty. Vasya ...

  10. Fiddler 模拟post 提交

    在使用Fiddler 提交post表单的时候, 一定要加上以下code: Content-Type: application/x-www-form-urlencoded 意思为: 窗体数据被编码为名称 ...