摘要: Primary Key Constraints:A primary key constraint enforces uniqueness of rows and also disallows NULLs in the constraint attributes.ALTER TABLE dbo.EmployeesADD CONSTRAINT PK_Employees PRIMARY KEY(empid);Unique Constraints:A unique constraint enforces uniqueness of rows, allowing you to implement the 阅读全文
posted @ 2011-06-24 17:10 HelloWorld.Michael 阅读(180) 评论(0) 推荐(0)
摘要: DDL: Data Definition Language ,deals with object definitions and includes statements such as CREATE, ALTER, and DROP.DML : Data Manipulation Language ,allows you to query and modify data and includes statements such as SELECT, INSERT, UPDATE, DELETE, and MERGE.DCL : Data Control Language ,deals with 阅读全文
posted @ 2011-06-22 14:20 HelloWorld.Michael 阅读(158) 评论(0) 推荐(0)
摘要: What happens if the records in the database that are represented by the entity classes have been changed after reading the record? The answer depends on the ConcurrencyMode property that is set with the model. With every property of an entity object, you can configure the ConcurrencyMode to Fixed or 阅读全文
posted @ 2011-06-16 15:37 HelloWorld.Michael 阅读(168) 评论(0) 推荐(0)
摘要: If the entity object is already inside the object context, the existing one is used; otherwise it is fetched newly from the database.Invoking the method ApplyCurrentValues() passes the modified entity object to the object context,and if there are changes, then the changes are done within the existin 阅读全文
posted @ 2011-06-16 15:13 HelloWorld.Michael 阅读(188) 评论(0) 推荐(0)
摘要: Majors functions and properties of ObjectContext class://// Summary:// Gets the object state manager used by the object context to track object// changes.//// Returns:// The System.Data.Objects.ObjectStateManager used by this System.Data.Objects.ObjectContext.public ObjectStateManager ObjectStateMan 阅读全文
posted @ 2011-06-16 14:46 HelloWorld.Michael 阅读(344) 评论(0) 推荐(0)
摘要: The ObjectStateManager is used by the object context to keep track of entities that are loaded into the context.// Summary: // Occurs when entities are added to or removed from the state manager. public event CollectionChangeEventHandler ObjectStateManagerChanged;If two different queries are done th 阅读全文
posted @ 2011-06-16 13:58 HelloWorld.Michael 阅读(274) 评论(0) 推荐(0)
摘要: Database :有三种方式来进行EF查询:LINQ to Entities, Entity SQL,和 Query Builder1.获取所有的Racer(Query Builder):using (Formula1Entities data = new Formula1Entities(connection)) { ObjectSet<Racer> racers = data.Racers; Console.WriteLine(racers.CommandText); Console.WriteLine(racers.ToTraceString()); }racers.Com 阅读全文
posted @ 2011-06-16 13:28 HelloWorld.Michael 阅读(958) 评论(0) 推荐(0)
摘要: 在Entity Framework中,可以通过属性的方式来访问有外键关系的表。当通过这种方式来访问的时候,存在一个何时加载关系表的问题。一共有lazy, delayed, eager 这三种方式。默认的方式是lazy。 public EFDemoEntities() : base("name=EFDemoEntities", "EFDemoEntities") { this.ContextOptions.LazyLoadingEnabled = true; OnContextCreated(); }Lazy方式载入数据:当要访问外键表的数据的时候才会载入 阅读全文
posted @ 2011-06-15 18:32 HelloWorld.Michael 阅读(188) 评论(0) 推荐(0)
摘要: To retrieve data from the database, the ObjectContext class is needed. This class defi nes the mapping fromthe entity objects to the database.The ObjectContext class provides several services to the caller:1.It keeps track of entity objects that are already retrieved. If the object is queried again, 阅读全文
posted @ 2011-06-15 17:20 HelloWorld.Michael 阅读(197) 评论(0) 推荐(0)
摘要: static void Main(string[] args) { try { string[] groups = new string[] { "Admin", "Back_End", "CSharp", "Developer", "Faserati", "Flex", "Front-End", "HTML", "JS", "SQL", "Teacher", "Te 阅读全文
posted @ 2011-06-15 15:01 HelloWorld.Michael 阅读(3204) 评论(0) 推荐(0)