http://msdn.microsoft.com/zh-cn/library/bb397924.aspx LINQ 查询操作中的类型关系 (C#)
使用一个人类发明快速检索的方法
// Northwnd inherits from System.Data.Linq.DataContext. Northwnd nw = new Northwnd(@"northwnd.mdf"); // or, if you are not using SQL Server Express // Northwnd nw = new Northwnd("Database=Northwind;Server=server_name;Integrated Security=SSPI"); var companyNameQuery = from cust in nw.Customers where cust.City == "London" select cust.CompanyName; foreach (var customer in companyNameQuery) { Console.WriteLine(customer); }
在上面的代码中,创建了 nw 对象来表示 Northwind 数据库,将 Customers 表作为目标,筛选出了来自 London的 Customers 行,并选择了一个表示 CompanyName 的字符串以进行检索。
执行循环时,将检索到 CompanyName 值的集合
http://msdn.microsoft.com/zh-cn/library/windowsphone/develop/bb399398(v=vs.100).aspx
http://www.cnblogs.com/lyj/archive/2008/01/28/1056133.html
Linq:基本语法form ,select, where(2)
http://www.cnblogs.com/liulun/archive/2009/06/02/1494740.html
时间排序
string[] datatime = { "2014-03-28 19:21:03", "2014-03-28 12:39:14", "2014-03-28 13:52:49", "2014-03-29 20:23:36", "2014-03-29 18:32:35", "2014-03-29 18:02:49", "2014-03-29 07:46:48", "2014-03-30 13:28:40", "2014-03-30 19:30:36", "2014-03-30 23:58:53" };
List<Product> msgs = new List<Product>();
for (int i = 0; i < datatime.Length; i++)
{
Product p1 = new Product();
p1.Name = "张" + i + " ";
p1.Age = Convert.ToString(20 + new Random().Next(0, 12));
p1.Data = datatime[i];
msgs.Add(p1);
}
var dor = from d in msgs orderby d.Data select d;
this.listBox1.ItemsSource = dor;
using (PersonDB per = new PersonDB())
{
if (!per.DatabaseExists())
per.CreateDatabase();
Person p1 = new Person();
p1.Name = "张三";
p1.Age = 3;
per.Persons.InsertOnSubmit(p1);
Classes c1 = new Classes();
c1.CName = "san";
c1.Content = "111";
per.Classesss.InsertOnSubmit(c1);
per.SubmitChanges();
}
这个俩个表都插入了
http://blog.csdn.net/qinyuanpei/article/details/23869275 [Unity3D]Unity3D游戏开发之仿仙剑奇侠传角色死亡效果实现