EF(EntityFrameWork) ORM(对象关系映射框架/数据持久化框架),根据实体对象操作数据表中数据的一种面向对象的操作框架,底层也是调用ADO.NET

ASP.NET MVC 项目会自动导入MVC程序集,因为默认.NET环境(GAC)中没有这个程序集

 create database MyFirstEF
on primary
(
name='MyFirstEF.mdf',
--修改为自己电脑上SQL DB路径
filename='E:\ProgramMSSQLServerDB\MyFirstEF.mdf',
size=5mb,
maxsize=100mb,
filegrowth=10%
)
log on
(
name='MyFirstEF_log.ldf',
--修改为自己电脑上SQL DB路径
filename='E:\ProgramMSSQLServerDB\MyFirstEF_log.ldf',
size=2mb,
maxsize=100mb,
filegrowth=5mb
)
go use MyFirstEF
go create table CustomerInfo
(
id int identity(1,1) primary key,
customerName nvarchar(100) not null,
customerDate datetime
)
go insert into CustomerInfo values('aaaaa',getdate())
go select * from CustomerInfo
go create table OrderInfo
(
id int identity(1,1) primary key,
orderName nvarchar(100),
customerId int
)
go alter table OrderInfo
add constraint FK_OrderInfo_CustomerInfo
foreign key(customerId) references CustomerInfo(id)
on delete cascade
on update cascade go select * from CustomerInfo
select * from OrderInfo

create SQL

1:LINQ[Language Integrated Query]/Lambda 基本查询

DbContext context = new MyFirstEFEntities();
// LINQ 基本查询
var rows = from c in context.Set<CustomerInfo>()
select c;
//返回的是SQL文
Console.WriteLine(rows);
Console.WriteLine(rows.Count()); //Lambda 基本查询
var rows1 = context.Set<CustomerInfo>().Select(c => c);
Console.WriteLine(rows1);
Console.WriteLine(rows1.Count());

对应SQL为:

--基本查询
SELECT
[Extent1].[id] AS [id],
[Extent1].[customerName] AS [customerName],
[Extent1].[customerDate] AS [customerDate]
FROM [dbo].[CustomerInfo] AS [Extent1]

2:LINQ/Lambda 单条件查询

DbContext context = new MyFirstEFEntities();

//LINQ 单条件查询
var rows = from c in context.Set<CustomerInfo>()
where c.id >
select c;
Console.WriteLine(rows);
Console.WriteLine(rows.Count()); //Lambda 单条件查询
var rows1 = context.Set<CustomerInfo>().Where(c => (c.id > ));
Console.WriteLine(rows1);
Console.WriteLine(rows1.Count());

对应SQL为:

--单条件查询
SELECT
[Extent1].[id] AS [id],
[Extent1].[customerName] AS [customerName],
[Extent1].[customerDate] AS [customerDate]
FROM [dbo].[CustomerInfo] AS [Extent1]
WHERE [Extent1].[id] > 2

3:LINQ/Lambda 多条件查询

DbContext context = new MyFirstEFEntities();

//LINQ 多条件查询
var rows = from c in context.Set<CustomerInfo>()
where c.id > && c.customerName.Contains("today")
select c;
Console.WriteLine(rows);
Console.WriteLine(rows.Count()); //Lambda 多条件查询
var rows1 = context.Set<CustomerInfo>().Where(c => (c.id > ) && (c.customerName.Contains("today")));
Console.WriteLine(rows1);
Console.WriteLine(rows1.Count());

对应SQL为:

--多条件查询
SELECT
[Extent1].[id] AS [id],
[Extent1].[customerName] AS [customerName],
[Extent1].[customerDate] AS [customerDate]
FROM [dbo].[CustomerInfo] AS [Extent1]
WHERE ([Extent1].[id] > 2) AND ([Extent1].[customerName] LIKE N'%today%')

4:LINQ/Lambda 连接查询

DbContext context = new MyFirstEFEntities();

//LINQ 连接查询
var rows = from c in context.Set<CustomerInfo>()
join o in context.Set<OrderInfo>() on c.id equals o.customerId
select c;
//连接查询相当于是Inner join
Console.WriteLine(rows);
Console.WriteLine(rows.Count()); //Lambda 连接查询
var rows1 = context.Set<CustomerInfo>().Join(context.Set<OrderInfo>(), c => c.id, o => o.customerId, (c, o) => c);
Console.WriteLine(rows1);
Console.WriteLine(rows1.Count());

对应SQL为:

--连接查询
SELECT
[Extent1].[id] AS [id],
[Extent1].[customerName] AS [customerName],
[Extent1].[customerDate] AS [customerDate]
FROM [dbo].[CustomerInfo] AS [Extent1]
INNER JOIN [dbo].[OrderInfo] AS [Extent2] ON [Extent1].[id] = [Extent2].[customerId]

5:LINQ:多from查询:专用于有导航属性的查询(LINQ特有)

DbContext context = new MyFirstEFEntities();

//多from查询:专用于有导航属性的查询(LINQ特有)
//select CustomerInfo
var rows = from c in context.Set<CustomerInfo>()
from o in c.OrderInfoes
where c.id > && o.orderName.Contains("car")
select c;
Console.WriteLine(rows);
Console.WriteLine(rows.Count()); //select OrderInfo
var rows1 = from c in context.Set<CustomerInfo>()
from o in c.OrderInfoes
where c.id > && o.orderName.Contains("car")
select o; Console.WriteLine(rows1);
Console.WriteLine(rows1.Count());

对应SQL为:

--多from查询:专用于有导航属性的查询(LINQ特有)
--select CustomerInfo
SELECT
[Extent1].[id] AS [id],
[Extent1].[customerName] AS [customerName],
[Extent1].[customerDate] AS [customerDate]
FROM [dbo].[CustomerInfo] AS [Extent1]
INNER JOIN [dbo].[OrderInfo] AS [Extent2] ON [Extent1].[id] = [Extent2].[customerId]
WHERE ([Extent1].[id] > 2) AND ([Extent2].[orderName] LIKE N'%car%') --select OrderInfo
SELECT
[Extent1].[id] AS [id],
[Extent1].[orderName] AS [orderName],
[Extent1].[customerId] AS [customerId]
FROM [dbo].[OrderInfo] AS [Extent1]
WHERE ([Extent1].[customerId] IS NOT NULL) AND ([Extent1].[customerId] > 2) AND ([Extent1].[orderName] LIKE N'%car%')

6:LINQ/Lambda 查询部分列(指定列)

DbContext context = new MyFirstEFEntities();

//LINQ 查询部分列(指定列)
var rows = from c in context.Set<CustomerInfo>()
select new { Id = c.id, Name = c.customerName };
Console.WriteLine(rows);
foreach (var row in rows)
{
Console.WriteLine(row.Id + ":" + row.Name);
} //Lambda 查询部分列(指定列)
var rows1 = context.Set<CustomerInfo>().Select(c => (new { Id = c.id, Name = c.customerName }));
foreach (var row in rows1)
{
Console.WriteLine(row.Id + ":" + row.Name);
}

对应SQL为:

--查询部分列(指定列)
SELECT
[Extent1].[id] AS [id],
[Extent1].[customerName] AS [customerName]
FROM [dbo].[CustomerInfo] AS [Extent1]

7:LINQ/Lambda 查询多个表格部分列(指定列)

DbContext context = new MyFirstEFEntities();

//LINQ 查询多个表格部分列
var rows = from c in context.Set<CustomerInfo>()
join o in context.Set<OrderInfo>()
on c.id equals o.customerId
select new { CustomerName = c.customerName, OrderName = o.orderName };
Console.WriteLine(rows);
Console.WriteLine(rows.Count()); var rows1 = context.Set<CustomerInfo>().Join(context.Set<OrderInfo>(), c => c.id, o => o.customerId, (c, o) => (new { CustomerName = c.customerName, OrderName = o.orderName }));
Console.WriteLine(rows1);
Console.WriteLine(rows1.Count());

对应SQL为:

--查询多个表格部分列(指定列)
SELECT
[Extent1].[id] AS [id],
[Extent1].[customerName] AS [customerName],
[Extent2].[orderName] AS [orderName]
FROM [dbo].[CustomerInfo] AS [Extent1]
INNER JOIN [dbo].[OrderInfo] AS [Extent2] ON [Extent1].[id] = [Extent2].[customerId]

8:Lambda:分页查询 lambda特有 OrderBy/Skip/Take 

DbContext context = new MyFirstEFEntities();

int pageSize = ;
int pageIndex = ;
//需要构建出startIndex 和 EndedIndex
var rows = context.Set<CustomerInfo>().OrderBy(c => c.id).Skip(pageSize * (pageIndex - )).Take();
Console.WriteLine(rows);
Console.WriteLine(rows.Count());

对应SQL为:

--分页查询 lambda特有
SELECT TOP (2)
[Extent1].[id] AS [id],
[Extent1].[customerName] AS [customerName],
[Extent1].[customerDate] AS [customerDate]
FROM ( SELECT [Extent1].[id] AS [id], [Extent1].[customerName] AS [customerName], [Extent1].[customerDate] AS [customerDate], row_number() OVER (ORDER BY [Extent1].[id] ASC) AS [row_number]
FROM [dbo].[CustomerInfo] AS [Extent1]
) AS [Extent1]
WHERE [Extent1].[row_number] > 2
ORDER BY [Extent1].[id] ASC

9:Lambda:封装分页查询

DbContext context1 = new MyFirstEFEntities();

int pageSize = ;
int pageIndex = ; //var rows = context1.Set<CustomerInfo>().Where(c => c.id > 1).OrderBy(c => c.id).Skip(pageSize * (pageIndex - 1)).Take(pageSize);
//Console.WriteLine(rows);
//Console.WriteLine(rows.Count()); var rows1 = GetPageList<CustomerInfo, int>(context1, pageSize, pageIndex, c => c.id > , c => c.id);
Console.WriteLine(rows1);
Console.WriteLine(rows1.Count());
//泛型 委托 Lambda表达式
public static IQueryable<T> GetPageList<T, Tkey>(DbContext context, int pageSize, int pageIndex, Expression<Func<T, bool>> where, Expression<Func<T, Tkey>> orderBy) where T : class
{
var rows = context.Set<T>() //泛型约束,因为上下文的Set<T>()方法,对T有要求
.Where(where) //语法糖 将Lambda表达式封装为Expresson对象
.OrderBy(orderBy)
.Skip(pageSize * (pageIndex - ))
.Take(pageSize);
return rows;
}

对应SQL为:

SELECT TOP (2)
[Filter1].[id] AS [id],
[Filter1].[customerName] AS [customerName],
[Filter1].[customerDate] AS [customerDate]
FROM ( SELECT [Extent1].[id] AS [id], [Extent1].[customerName] AS [customerName], [Extent1].[customerDate] AS [customerDate], row_number() OVER (ORDER BY [Extent1].[id] ASC) AS [row_number]
FROM [dbo].[CustomerInfo] AS [Extent1]
WHERE [Extent1].[id] > 1
) AS [Filter1]
WHERE [Filter1].[row_number] > 2
ORDER BY [Filter1].[id] ASC

整体EF 查询Demo源代码:

using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Data.Entity.Infrastructure;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks; namespace _20160403_MyFirstEFDemo
{
class Program
{
static void Main(string[] args)
{ #region 方法
////EF context 对象
//MyFirstEFEntities context = new MyFirstEFEntities();
////add
//CustomerInfo customer = new CustomerInfo();
//customer.customerName = "Test1";
//customer.customerDate = DateTime.Now;
//context.CustomerInfoes.Add(customer);
//context.SaveChanges(); ////update
////1:先查询要修改的原数据
//CustomerInfo customer = context.CustomerInfoes.Find(1);
////2:设置修改后的值
//customer.customerDate = DateTime.Now;
////3:更新到数据库
//context.SaveChanges(); ////Read
//CustomerInfo customer = context.CustomerInfoes.Find(1);
//if (customer != null)
//{
// string strCustomerInfo = string.Format("name:{0},date:{1}", customer.customerName, customer.customerDate);
// Console.WriteLine(strCustomerInfo);
//} ////delete
//CustomerInfo customer = new CustomerInfo();
//customer.id = 1;
//context.CustomerInfoes.Attach(customer);
//context.CustomerInfoes.Remove(customer);
//context.SaveChanges();
#endregion #region 状态
//EF context 对象
//DbContext contextState = new MyFirstEFEntities(); ////add 1
//CustomerInfo customerState = new CustomerInfo();
//customerState.customerName = "testState1";
//customerState.customerDate = DateTime.Now;
//contextState.Set<CustomerInfo>().Add(customerState);
//contextState.SaveChanges(); ////add 2
//CustomerInfo customerState = new CustomerInfo() {
// customerName="stateTest111",
// customerDate=DateTime.Now
//};
//contextState.Entry<CustomerInfo>(customerState).State = System.Data.EntityState.Added;
//contextState.SaveChanges(); ////update 1
//CustomerInfo customerState = new CustomerInfo();
//customerState.id = 1;
//customerState.customerDate = DateTime.Now;
//customerState.customerName = "bbb"; ////1: 标记当前对象,必须把必填字段都填写,否则会报错:System.Data.Entity.Validation.DbEntityValidationException
////1: 若此时未更新 非必填字段,则数据库会把非必填字段更新为null
//contextState.Entry<CustomerInfo>(customerState).State = System.Data.EntityState.Modified;
//contextState.SaveChanges(); ////update 2
//CustomerInfo customerState = new CustomerInfo();
//customerState.id = 1;
//customerState.customerName = "dfdfdfdf"; ////2: 针对某个属性,进行状态跟踪设置
////** 2.1: 如果使用 Entry 附加 实体对象到数据容器中,则需要手动 设置 实体包装类的对象 的 状态为 Unchanged**
////** 2.1: entry.State = System.Data.EntityState.Unchanged;
//DbEntityEntry<CustomerInfo> entry = contextState.Entry<CustomerInfo>(customerState);
//entry.State = System.Data.EntityState.Unchanged;
//entry.Property("customerName").IsModified = true;
//contextState.SaveChanges(); ////update 3
//CustomerInfo customerState = new CustomerInfo();
//customerState.id = 1;
//customerState.customerName = "aaaaa"; ////** 2.2: 如果使用 Attach 就不需要这句
////** 2.2: entry.State = System.Data.EntityState.Unchanged;
//contextState.Set<CustomerInfo>().Attach(customerState);///直接针对属性进行状态设置,但是当前对象并没有被上下文跟踪
//contextState.Entry<CustomerInfo>(customerState).Property("customerName").IsModified = true;
//contextState.SaveChanges(); ////delete
//CustomerInfo customerState = new CustomerInfo()
//{
// id = 2
//};
//contextState.Entry<CustomerInfo>(customerState).State = System.Data.EntityState.Deleted;
//contextState.SaveChanges(); #endregion #region 多表增加操作
//DbContext dbContext = new MyFirstEFEntities(); //CustomerInfo customerInfo = new CustomerInfo()
//{
// customerName = "duobiaocaozuo",
// customerDate = DateTime.Now
//};
//dbContext.Set<CustomerInfo>().Add(customerInfo); //OrderInfo orderInfo1 = new OrderInfo()
//{
// orderName = "bike1",
// customerId = customerInfo.id
//};
//dbContext.Set<OrderInfo>().Add(orderInfo1); //OrderInfo orderInfo2 = new OrderInfo()
//{
// orderName = "bike2",
// customerId = customerInfo.id
//};
//dbContext.Set<OrderInfo>().Add(orderInfo2); //dbContext.SaveChanges();
#endregion #region 导航属性
//DbContext dbContext = new MyFirstEFEntities(); //CustomerInfo customerInfo = new CustomerInfo()
//{
// customerName = "daohangshuxing",
// customerDate = DateTime.Now
//}; //customerInfo.OrderInfoes.Add(new OrderInfo()
//{
// orderName = "car1",
//}); //customerInfo.OrderInfoes.Add(new OrderInfo()
//{
// orderName = "car2"
//}); //dbContext.Set<CustomerInfo>().Add(customerInfo); //dbContext.SaveChanges(); #endregion #region 查询LINQ Lambda表达式 EF
//DbContext context = new MyFirstEFEntities();
//// LINQ 基本查询
//var rows = from c in context.Set<CustomerInfo>()
// select c;
////返回的是SQL文
//Console.WriteLine(rows);
//Console.WriteLine(rows.Count()); ////Lambda 基本查询
//var rows1 = context.Set<CustomerInfo>().Select(c => c);
//Console.WriteLine(rows1);
//Console.WriteLine(rows1.Count()); ////LINQ 单条件查询
//var rows = from c in context.Set<CustomerInfo>()
// where c.id > 2
// select c;
//Console.WriteLine(rows);
//Console.WriteLine(rows.Count()); ////Lambda 单条件查询
//var rows1 = context.Set<CustomerInfo>().Where(c => (c.id > 2));
//Console.WriteLine(rows1);
//Console.WriteLine(rows1.Count()); ////LINQ 多条件查询
//var rows = from c in context.Set<CustomerInfo>()
// where c.id > 2 && c.customerName.Contains("today")
// select c;
//Console.WriteLine(rows);
//Console.WriteLine(rows.Count()); ////Lambda 多条件查询
//var rows1 = context.Set<CustomerInfo>().Where(c => (c.id > 2) && (c.customerName.Contains("today")));
//Console.WriteLine(rows1);
//Console.WriteLine(rows1.Count()); ////LINQ 连接查询
//var rows = from c in context.Set<CustomerInfo>()
// join o in context.Set<OrderInfo>() on c.id equals o.customerId
// select c;
////连接查询相当于是Inner join
//Console.WriteLine(rows);
//Console.WriteLine(rows.Count()); ////Lambda 连接查询
//var rows1 = context.Set<CustomerInfo>().Join(context.Set<OrderInfo>(), c => c.id, o => o.customerId, (c, o) => c);
//Console.WriteLine(rows1);
//Console.WriteLine(rows1.Count()); ////多from查询:专用于有导航属性的查询(LINQ特有)
////select CustomerInfo
//var rows = from c in context.Set<CustomerInfo>()
// from o in c.OrderInfoes
// where c.id > 2 && o.orderName.Contains("car")
// select c;
//Console.WriteLine(rows);
//Console.WriteLine(rows.Count()); ////select OrderInfo
//var rows1 = from c in context.Set<CustomerInfo>()
// from o in c.OrderInfoes
// where c.id > 2 && o.orderName.Contains("car")
// select o; //Console.WriteLine(rows1);
//Console.WriteLine(rows1.Count()); ////LINQ 查询部分列(指定列)
//var rows = from c in context.Set<CustomerInfo>()
// select new { Id = c.id, Name = c.customerName };
//Console.WriteLine(rows);
//foreach (var row in rows)
//{
// Console.WriteLine(row.Id + ":" + row.Name);
//} ////Lambda 查询部分列(指定列)
//var rows1 = context.Set<CustomerInfo>().Select(c => (new { Id = c.id, Name = c.customerName }));
//foreach (var row in rows1)
//{
// Console.WriteLine(row.Id + ":" + row.Name);
//} ////LINQ 查询多个表格部分列
//var rows = from c in context.Set<CustomerInfo>()
// join o in context.Set<OrderInfo>()
// on c.id equals o.customerId
// select new { CustomerName = c.customerName, OrderName = o.orderName };
//Console.WriteLine(rows);
//Console.WriteLine(rows.Count()); //var rows1 = context.Set<CustomerInfo>().Join(context.Set<OrderInfo>(), c => c.id, o => o.customerId, (c, o) => (new { CustomerName = c.customerName, OrderName = o.orderName }));
//Console.WriteLine(rows1);
//Console.WriteLine(rows1.Count()); ////分页查询 lambda特有
//int pageSize = 2;
//int pageIndex = 2;
////需要构建出startIndex 和 EndedIndex
//var rows = context.Set<CustomerInfo>().OrderBy(c => c.id).Skip(pageSize * (pageIndex - 1)).Take(2);
//Console.WriteLine(rows);
//Console.WriteLine(rows.Count()); #endregion #region Lambda 分页封装
//DbContext context1 = new MyFirstEFEntities(); //int pageSize = 2;
//int pageIndex = 2; ////var rows = context1.Set<CustomerInfo>().Where(c => c.id > 1).OrderBy(c => c.id).Skip(pageSize * (pageIndex - 1)).Take(pageSize);
////Console.WriteLine(rows);
////Console.WriteLine(rows.Count()); //var rows1 = GetPageList<CustomerInfo, int>(context1, pageSize, pageIndex, c => c.id > 1, c => c.id);
//Console.WriteLine(rows1);
//Console.WriteLine(rows1.Count()); #endregion Console.WriteLine("OK");
Console.ReadKey();
} //泛型 委托 Lambda表达式
public static IQueryable<T> GetPageList<T, Tkey>(DbContext context, int pageSize, int pageIndex, Expression<Func<T, bool>> where, Expression<Func<T, Tkey>> orderBy) where T : class
{
var rows = context.Set<T>() //泛型约束,因为上下文的Set<T>()方法,对T有要求
.Where(where) //语法糖 将Lambda表达式封装为Expresson对象
.OrderBy(orderBy)
.Skip(pageSize * (pageIndex - ))
.Take(pageSize);
return rows;
}
}
}

EF查询Demo源代码

参考链接:

ASP.NET MVC EF直接更新数据(不需查询):http://www.cnblogs.com/Dr-Hao/p/5255630.html

ASP.NET EF 使用LinqPad 快速学习Linq:http://www.cnblogs.com/Dr-Hao/p/5357112.html

ASP.NET EF(LINQ/Lambda查询)的更多相关文章

  1. 第二节: 比较EF的Lambda查询和Linq查询写法的区别

    简介 在前面EF的介绍中,曾多次提到过EF可以使用Lambda和Linq来完成对数据库的访问,这两种的语法的具体使用和注意事项在前面的DotNet进阶的系列章节中已经详细介绍过了,本次借着EF章节,重 ...

  2. ASP.NET EF 使用LinqPad 快速学习Linq

    使用LinqPad这个工具可以很快学习并掌握linq[Language Integrated Query] linqPad官方下载地址:http://www.linqpad.net/ linqPad4 ...

  3. js_html_input中autocomplete="off"在chrom中失效的解决办法 使用JS模拟锚点跳转 js如何获取url参数 C#模拟httpwebrequest请求_向服务器模拟cookie发送 实习期学到的技术(一) LinqPad的变量比较功能 ASP.NET EF 使用LinqPad 快速学习Linq

    js_html_input中autocomplete="off"在chrom中失效的解决办法 分享网上的2种办法: 1-可以在不需要默认填写的input框中设置 autocompl ...

  4. EF删除,查询,Linq查询,Lambda查询,修改链接字符串

    (1)//删除操作 public bool delete() { try { a_context = new AEntities(); b1 = new Table_1(); //删除只需要写主键就行 ...

  5. EF下lambda与linq查询&&扩展方法

    1. linq查询数据 WebTestDBEntities db = new WebTestDBEntities(); 1.1 linq查询所有列数据 var userInfoList = from ...

  6. 浅谈sql 、linq、lambda 查询语句的区别

    浅谈sql .linq.lambda 查询语句的区别 LINQ的书写格式如下: from 临时变量 in 集合对象或数据库对象 where 条件表达式 [order by条件] select 临时变量 ...

  7. EF+LINQ事物处理 C# 使用NLog记录日志入门操作 ASP.NET MVC多语言 仿微软网站效果(转) 详解C#特性和反射(一) c# API接受图片文件以Base64格式上传图片 .NET读取json数据并绑定到对象

    EF+LINQ事物处理   在使用EF的情况下,怎么进行事务的处理,来减少数据操作时的失误,比如重复插入数据等等这些问题,这都是经常会遇到的一些问题 但是如果是我有多个站点,然后存在同类型的角色去操作 ...

  8. Linq 动态查询排序

    Linq的排序一般是这样写的: query.OrderBy(x => x.Tel).Skip().Take(); 实际使用中排序字段可能是通过字符类型的参数来设置的,于是想这样实现: query ...

  9. 解析ASP.NET Mvc开发之查询数据实例

    目录: 1)从明源动力到创新工场这一路走来 2)解析ASP.NET WebForm和Mvc开发的区别 ------------------------------------------------- ...

随机推荐

  1. utuntu下安装eclipse+jdk

    安装jdk: 1.下载一个可以用的jdk压缩包.下载地址:http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads- ...

  2. Delphi ADOQuery多个参数重复 改编技巧

    今天看了多年前的一个帖子,发现回答不合理,有些还将其归为delphi的bug.其实主要是没有灵活应用参数. ADOQUERY查询时,这样不行,结果不正确. WITH ADOQUERY1 DO BEGI ...

  3. jquery不能是使用普通的for循环 因为普通的for循环通过下表获取对象 如果通过下表获取对象的话 会转成dom对象

    jquery不能是使用普通的for循环 因为普通的for循环通过下表获取对象 如果通过下表获取对象的话 会转成dom对象

  4. NetBeans IDE驱动报错The path to the driver executable must be set by the web driver.chrome.driver.system property......

    问题:defaulstUserDataPath=C:\\Users\\user1\\AppData\\Local\\Google\\Chrome\\User Data\\Defaul 编译失败 解决 ...

  5. BZOJ4922 Karp-de-Chant Number(贪心+动态规划)

    首先将每个括号序列转化为三元组(ai,bi,ci),其中ai为左括号-右括号数量,bi为前缀最小左括号-右括号数,ci为序列长度.问题变为在满足Σai=0,bi+Σaj>=0 (j<i)的 ...

  6. 已知UIScrollView放大后的Frame和放大之前的Frame计算放大的瞄点坐标

    有时候在缩放后,需要知道该次缩放是在哪个坐标开始缩放的.如上篇已知缩放的点,然后在该点对其缩放.本篇其实是逆运算 (x,y)就是当初在该点进行缩放 化简之后很简单,代码如下: func getZoom ...

  7. day29:关闭服务|

    1. 在centos6系统里,我们可以使用ntsysv关闭不需要开机启动的服务,当然也可以使用chkconfig工具来实现. 写一个shell脚本,用chkconfig工具把不常用的服务关闭.脚本需要 ...

  8. RDD 算子补充

    一.RDD算子补充 1.mapPartitions         mapPartitions的输入函数作用于每个分区, 也就是把每个分区中的内容作为整体来处理.   (map是把每一行) mapPa ...

  9. 【bzoj4002】有意义的字符串

    Portal --> bzoj4002 Solution ​ 虽然说这题有点强行但是感觉还是挺妙的,给你通项让你反推数列的这种==有点毒 ​​ 补档时间 ​ 首先有一个东西叫做特征方程,我们可以 ...

  10. php 阿拉伯数字转中文

    function numToWord($num){$chiNum = array('零', '一', '二', '三', '四', '五', '六', '七', '八', '九');$chiUni = ...