摘要: 在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 阅读(190) 评论(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 阅读(198) 评论(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 阅读(3206) 评论(0) 推荐(0)
摘要: 使用.Net来访问AD的时候,通常会先创建DirectoryEntry对象,值得注意的是,构建DirectoryEntry对象的时候并没有真正的从AD Server上获取数据。当访问DirectoryEntry的某个属性的时候,会把DirectoryEntry对象中的所有数据获取下来,并将这些数据放到AD的Cache中。有的时候可能需要修改AD对象的一些信息,可能会写如下的代码: 1 using (var de = new DirectoryEntry()) 2 { 3 de.Path = "LDAP://magellan/CN=Christian Nagel, " + 4 阅读全文
posted @ 2011-06-15 09:58 HelloWorld.Michael 阅读(618) 评论(0) 推荐(0)
摘要: 获取一个DirectoryEntry下面所有的节点: using (var de = new DirectoryEntry()) { de.Path = "LDAP://magellan/OU=thinktecture, DC=cninnovation, DC=local"; Console.WriteLine("Children of {0}", de.Name); foreach (DirectoryEntry obj in de.Children) { Console.WriteLine(obj.Name); } }通过设置SchemaFilter 阅读全文
posted @ 2011-06-15 09:48 HelloWorld.Michael 阅读(481) 评论(1) 推荐(0)