poco

POCO's, behavior and Peristance Igorance

我们两清 提交于 2019-11-26 11:35:57
问题 From what I have read POCO classes should be persistence ignorant and should not contain references to repositories. Q1. Given the above, how would I populate the QuestionBlocks collection? I have read that POCO\'s should contain behavior so you don\'t end of with an anemic model, so I\'m kind of confused as how one is supposed to do that without persistence. If that\'s the case then what kind of behavior would you put in a POCO? Ex: public class Survey { public int SurveyId { get; set; }

ASP.NET MVC / EF4 / POCO / Repository - How to Update Relationships?

半世苍凉 提交于 2019-11-26 10:59:27
问题 I have a 1..* relationship between Review and Recommendations . The relevant portion of my model (which is also the POCO mapped by EF4): public class Review { public ICollection<Recommendations> Recommendations { get; set; } } On an Edit View , i represent the Recommendations as a set of checkboxes. When i try and add a new Recommendation as part of editing the Review (e.g check another box), nothing is happening - and i know why... I use the \"stub technique\" to update my entities - e.g i

How to map table splitting in EF Code First?

女生的网名这么多〃 提交于 2019-11-26 09:54:51
问题 How can I map table splitting with EF Code First? Table splitting for EDMX is described for example here. It allows mapping two entities with 1:1 relation into same table. I know I can do the similar mapping with entity and complex type but the big difference is that complex type can\'t be lazy loaded (or not loaded at all) which is the main reason for table splitting. 回答1: Here is how I just got EF 4.1 (RC) to do table splitting in Code First. Define your two entities. Make sure to include

How to declare one to one relationship using Entity Framework 4 Code First (POCO)

南笙酒味 提交于 2019-11-26 07:34:39
问题 How to declare a one to one relationship using Entity Framework 4 Code First (POCO)? I found this question (one-to-one relationships in Entity Framework 4) , but the article that the answer references was not useful (there is one line of code that is a 1-1 relationship, but no mention of how to define it). 回答1: Are you just looking for something like this? public class User { public int Id { get; set; } public string Username { get; set; } public Profile Profile { get; set; } public int

Entity Framework 4 / POCO - Where to start? [closed]

点点圈 提交于 2019-11-26 06:52:09
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 5 years ago . I\'ve been programming for a while and have used LINQ-To-SQL and LINQ-To-Entities before (although when using entities it has been on a Entity/Table 1-1 relationship - ie not much different than L2SQL) I\'ve been doing a lot of reading about Inversion of Control, Unit of Work, POCO and repository patterns and

How to add validation to my POCO(template) classes

北城余情 提交于 2019-11-26 03:58:40
问题 So I used this tutorial to generate my poco classes which I am to use throughout my aplication.. the problem is that Im not supposed to modify the generated cs files cause they get autoregenerated... How do I add attributes like [Required] and stuff like that?? please help 回答1: You can't add it directly (unless you modify T4 template to create them for you) but you can try to use trick introduced in ASP.NET dynamic data. All POCO classes are defined as partial. So lets define your partial

&#39;POCO&#39; definition

旧时模样 提交于 2019-11-26 01:36:05
问题 Can someone define what exactly \'POCO\' means? I am encountering the term more and more often, and I\'m wondering if it is only about plain classes or it means something more? 回答1: "Plain Old C# Object" Just a normal class, no attributes describing infrastructure concerns or other responsibilities that your domain objects shouldn't have. EDIT - as other answers have stated, it is technically "Plain Old CLR Object" but I, like David Arno comments, prefer "Plain Old Class Object" to avoid ties

Update relationships when saving changes of EF4 POCO objects

你说的曾经没有我的故事 提交于 2019-11-26 01:19:02
问题 Entity Framework 4, POCO objects and ASP.Net MVC2. I have a many to many relationship, lets say between BlogPost and Tag entities. This means that in my T4 generated POCO BlogPost class I have: public virtual ICollection<Tag> Tags { // getter and setter with the magic FixupCollection } private ICollection<Tag> _tags; I ask for a BlogPost and the related Tags from an instance of the ObjectContext and send it to another layer (View in the MVC application). Later I get back the updated BlogPost

Using JsonConvert.DeserializeObject to deserialize Json to a C# POCO class

不问归期 提交于 2019-11-26 00:43:23
问题 Here is my simple User POCO class: /// <summary> /// The User class represents a Coderwall User. /// </summary> public class User { /// <summary> /// A User\'s username. eg: \"sergiotapia, mrkibbles, matumbo\" /// </summary> public string Username { get; set; } /// <summary> /// A User\'s name. eg: \"Sergio Tapia, John Cosack, Lucy McMillan\" /// </summary> public string Name { get; set; } /// <summary> /// A User\'s location. eh: \"Bolivia, USA, France, Italy\" /// </summary> public string

Self Tracking Entities vs POCO Entities

倾然丶 夕夏残阳落幕 提交于 2019-11-26 00:29:02
问题 We are starting a new web based product in which we are planning to expose our business logic through WCF services. We will be using ASP.NET 4.0, C#, EF 4.0. In future we want to build iphone applications and WPF applications based on the services. I have been reading a lot about using POCO vs Self Tracking Entities (STE) and from my understand the STEs do not work well with the web scenario. Can anyone shed more light on this issue? 回答1: For me STE is absolutely wrong concept. It is just