1. C#中System.Environment.NewLine :::获取为此环境定义的换行字符串
2.db.Log = Console.Out;生成一个日志输出,显示 LINQ to SQL 生成的 SQL 命令。此日志记录功能(使用 Log)对调试有帮助,并有助于确定发送给数据库的命令是否准确地表示您的查询。
3.column属性 DbType = "Int NOT NULL IDENTITY" IsDbGenerated = true自动生成无需设置
4.外键的表示: [Association(Storage = "_Customer", ThisKey = "CustomerID")]
5.创建数据库的强类型化视图
之前:DataContext db = new DataContext (@"c:\linqtest5\northwnd.mdf");
// Get a typed table to run queries.
Table<Customer> Customers = db.GetTable<Customer>();
现在:
添加: public class Northwind : DataContext
{
public Table<Customer> Customer;
public Table<Order> Orders;
public Northwind(string connection) : base(connection) { }
}
则用: Northwind db = new Northwind(@"C:\linqtest5\northwnd.mdf"); 即可;