Linq101-Restriction
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的更多相关文章
- 关于Access restriction: The type 'Application' is not API (restriction on required library)
原文链接:http://rxxluowei.iteye.com/blog/671893 今天写第一次写JavaFX的入门程序就GG 遇到了导入API的问题,无奈疯狂地通过网络找解决方案.. 我的问题是 ...
- TNS-12540: TNS:internal limit restriction exceeded
应用程序以及客户端工具(Toad.PL/SQL Developer等)出现突然连接不上数据库服务器的情况,监听日志listener.log里面出现了TSN-12518与TSN-12540错误,如下所示 ...
- The constructor BASE64Encoder() is not accessible due to restriction on required library
在Eclipse中编写Java代码时,用到了BASE64Decoder,import sun.misc.BASE64Decoder;可是Eclipse提示:Access restriction : T ...
- Access restriction: The type TaskTopicResolver is not accessible due to restrict
Access restriction: The type TaskTopicResolver is not accessible due to restrict : Eclipse 默认把这些受访问 ...
- Eclipse 关于“The type * is not accessible due to restriction on required library”问题的解决办法
The type * is not accessible due to restriction on required library”的错误, 意思是所需要的类库由于受限制无法访问. 解决办法: 1 ...
- Access restriction错误解决办法
Access restriction错误, XX方法 is not accessible due to restriction on required library XXlib 解决方案: Ecli ...
- Access restriction: The type 'BASE64Encoder' is not API
问题的原因好像是这个方法不是安全的,所以不推荐使用,我是在做毕设时要用到的所以就直接用了(毕设要求没有那么严格的要求)
- PHPExcel中open_basedir restriction in effect的解决方法
用PHPExcel做导出execl的时候发现在本地没有问题,但是把网站传到租用的服务器的时候就报错,具体如下: Warning: realpath() [function.realpath]: ope ...
- The constructor BASE64Encoder() is not accessible due to restriction on required
在Eclipse中编写Java代码时,用到了BASE64Decoder,import sun.misc.BASE64Decoder;可是Eclipse提示: Access restriction : ...
- 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 ...
随机推荐
- linux中VI编辑器使用个人记录
VI编辑器有三种编辑模式:命令模式.最后行模式.文本编辑模式 启动VI后进入的第一种模式是”命令模式“.从命令模式可进入最后行模式和编辑模式.而后两种模式之间不能直接切换.必须按ESC键退回到命令模式 ...
- C++例题1:输出可打印字符
#include<iostream>#include<stdlib.h>#include<cctype>int main(){ int i;char a=0; fo ...
- java 反射 动态代理
在上一篇文章中介绍Java注解的时候,多次提到了Java的反射API.与javax.lang.model不同的是,通过反射API可以获取程序在运行时刻的内部结构.反射API中提供的动态代理也是非常强大 ...
- 【Java】理解 UDDI 注册中心的 WSDL
如何发布和查找 WSDL 服务描述 Web 服务描述语言(WSDL)有多种用法.特别是,根据应用程序的需要,WSDL 在 UDDI 注册中心有好几种使用方法.在这第 1 篇文章中(本系列共三篇),我们 ...
- ASP.NET内置对象
ASP.NET中有六个内置对象 Response:向客户端输出信息或设置客户端输出状态. Request:获取客户端信息. Server:访问服务器的方法和属性. Application:用于将信息保 ...
- HTML入门教程(全套)
http://www.rm5u.com/html_html.html http://learn.shayhowe.com/ moe.mwulu.com http://www.w3school.co ...
- Android 中使用MediaRecorder进行录像详解(视频录制)
在这里给出自己的一个测试DEMO,里面注释很详细.简单的视频录制功能. package com.video; import java.io.IOException; import android.ap ...
- bzoj3043
这道题完全没想出来,引自 http://blog.csdn.net/willinglive/article/details/38419573的题解 对于带有“将一段区间内的每个数全部加上某个值”这种操 ...
- COJ 0046 20701除法
20701除法 难度级别:B: 运行时间限制:1000ms: 运行空间限制:51200KB: 代码长度限制:2000000B 试题描述 输入正整数n,按从小到大的顺序输出所有满足表达式abcd ...
- LNMP一键安装脚本
#!/bin/bash #LNMP(Fastcgi) #CentOS + MySQL 5.5 #-- iptables -F iptables -X iptables -Z iptables -A I ...