poco

Why do navigation properties have to be public for a proxy to be created?

扶醉桌前 提交于 2020-03-22 08:04:26
问题 At http://msdn.microsoft.com/en-us/library/dd468057.aspx I read that all navigation properties for which I would like to have a change tracking proxy need to be public and virtual . From what I understand, the CLR creates subclasses of my POCOs dynamically, and it re-implements the properties to provide the requested behaviour. For this I undertand that the property needs to be virtual , and that it should have protected or higher accesability. However, if I want to use these for convenience

为什么使用ICollection而不是IEnumerable或List <T> 在多对多/一对多关系上?

雨燕双飞 提交于 2020-03-03 17:09:13
我在教程中看到了很多,导航属性为 ICollection<T> 。 这是对实体框架的强制性要求吗? 我可以使用 IEnumerable 吗? 使用 ICollection 而不是 IEnumerable 甚至 List<T> 的主要目的是什么? #1楼 ICollection<T> 是因为 IEnumerable<T> 接口没有提供添加项目,删除项目或修改集合的方式。 #2楼 使用 ICollection 的基本思想是提供一个接口,以只读方式访问一定数量的数据。 实际上,您具有 ICollection.Count 属性。 IEnumerable 更适用于某些数据链,在这些数据链中您读取直到某个逻辑点,使用者明确指定的某些条件或枚举结束为止。 #3楼 通常,您选择的内容取决于您需要使用的方法。 通常, IEnumerable<> (MSDN: http : //msdn.microsoft.com/zh-cn/library/system.collections.ienumerable.aspx )用于仅需要迭代的对象列表, ICollection<> ( MSDN: http : //msdn.microsoft.com/zh-cn/library/92t2ye13.aspx ),列出了需要迭代和修改的对象, List<> 列出了需要迭代的对象。 ,修改,排序等(有关完整列表

Entity Framework 4.1 reverse engineering code-only

跟風遠走 提交于 2020-01-23 12:12:15
问题 I am using Entity Framework 4.1 and want to take advantage of their code-only approach. In the video located at http://channel9.msdn.com/Events/TechEd/Europe/2010/DEV212 starting at 35:00 minutes in they show a tool that reverse engineers their POCOs from their existing database. I want to do this as I have an existing database. I have installed EF 4.1 and I can create POCO entities just fine but I can't seem to find the tool they used to create POCOs from the existing database. Was this tool

Entity Framework loading child collection with sort order

北战南征 提交于 2020-01-18 07:21:28
问题 I have two tables a parent and a child table. The child table has a column sortorder (a numeric value). Because of the missing support of the EF to persist a IList inclusive the sort order without exposing the sortorder (see: Entity Framework persisting child collection sort order) my child class has also a property SortOrder, so that i can store the children with the sort order. In contrast to the autor of the referenced question i try to load the children always sorted. So if i load a

Entity Framework loading child collection with sort order

扶醉桌前 提交于 2020-01-18 07:20:21
问题 I have two tables a parent and a child table. The child table has a column sortorder (a numeric value). Because of the missing support of the EF to persist a IList inclusive the sort order without exposing the sortorder (see: Entity Framework persisting child collection sort order) my child class has also a property SortOrder, so that i can store the children with the sort order. In contrast to the autor of the referenced question i try to load the children always sorted. So if i load a

CRUD operations with connected POCOs instead of disconnected POCOs in EF code first

こ雲淡風輕ζ 提交于 2020-01-16 19:30:10
问题 I have an classic 3 layer project, that has these layers: UI (WinForm Project) BLL DAL(using EF codefirst) My entities are disconnected POCO s and I used them to pass data between layers and used them to bind to the UI controls. I load a graph of some related entities to UI(e.g. Order with it's OrderLine s and Product of each OrderLine ), user may add some new entities, edit some others and delete some others entities in this graph, and then send this graph to DAL to persist this changes to

EF “Model First”: Create entity in edmx and db-table from class?

孤街浪徒 提交于 2020-01-16 05:26:17
问题 This question is part of my following one I already asked roughly 2.5 years ago: Entity Framework (.NET) Round-Trip Modelling with Model First? I wanted to ask if in the meantime, the following is possible (and from which version of EF upwards): We are currently using EF 5.0 with the "Model First" approach (VS 2012). After first problems, we managed to configure the two T4 templates for generating the DbContext-derived class and the POCOs so that if we need to map a new (or existing) database

What does “Create a domain model via POCO classes” means?

你离开我真会死。 提交于 2020-01-14 06:06:12
问题 I have an assessment to solve. In the project solution which is given to me, there is a .csv file expected from me to process it. Here is how it looks like; asset id,file_name,mime_type,created_by,email,country,description 51df6a98-614e-40ef-8885-95ae50940058,ElitProin.aam,application/x-authorware-map,sblack0,jmitchell0@huffingtonpost.com,United States,Maecenas ut massa quis augue luctus tincidunt. Nulla mollis molestie lorem. Quisque ut erat. 279899c1-bc63-495c-94c5-57f25c881ed2

EF 4: Problems understanding DetectChanges when using POCO (no self tracking ObjectContext)

荒凉一梦 提交于 2020-01-14 05:21:27
问题 I wonder if anyone can help me? I am having problems understanding why i need to issues DetectChanges on my POCO (non proxy) entities. Of course i have this line to ensure that proxies are not returned. context.ObjectStateManager.GetObjectStateEntry(order).State And doing some research it appears if i need to check the "state" of an object then i need to issue detechChanges But why would i need to check the State of an object? Basically I send along my POCO entity to a method that SAVES the

Entity Framework 4 - TPT Inheritance in Features CTP5 (code first): rename foreign key column on inherited table

一曲冷凌霜 提交于 2020-01-14 03:38:07
问题 I'm trying to convert an xml Entity Framework model to Code First (CTP5) one. I have to model a hierarchy which fits quite well the TPT pattern. The only problem I have is that the primary key/foreign key of the "inheriting" table has a different name from the primary key of the base class. These are the relevant fields of the involved tables CREATE TABLE site.Domains ( ID INT NOT NULL PRIMARY KEY, Domain NVARCHAR(128) NOT NULL ) CREATE TABLE site.MainSites ( FKDomainID INT NOT NULL PRIMARY