poco

Advice on POCO Validation with ASP.NET MVC/Entity Framework

大憨熊 提交于 2019-12-31 10:43:02
问题 Here's the scenario: ASP.NET MVC2 Web Application Entity Framework 4 (Pure POCO's, Custom Data Context) Repository Pattern Unit of Work Pattern Dependency Injection Service Layer mediating Controller -> Repository So basically, all the cool stuff. :) Flow of events for a basic UI operation ("Adding a Post"): Controller calls Add(Post) method on service layer Service layer calls Add(T) on repository Repository calls AddObject(T) on custom data context Controller calls Commit() on Unit of Work

Advice on POCO Validation with ASP.NET MVC/Entity Framework

拟墨画扇 提交于 2019-12-31 10:42:13
问题 Here's the scenario: ASP.NET MVC2 Web Application Entity Framework 4 (Pure POCO's, Custom Data Context) Repository Pattern Unit of Work Pattern Dependency Injection Service Layer mediating Controller -> Repository So basically, all the cool stuff. :) Flow of events for a basic UI operation ("Adding a Post"): Controller calls Add(Post) method on service layer Service layer calls Add(T) on repository Repository calls AddObject(T) on custom data context Controller calls Commit() on Unit of Work

Entity Framework 4 - TPH Inheritance in Features CTP5 (code first) with “IS NULL” discriminator

谁说胖子不能爱 提交于 2019-12-31 04:57:05
问题 Hey guys, I'm trying to create a TPH mapping on a hierarchy where the discriminating clause is the classical "IS NOT NULL" / "IS NULL" case. Here is the example, database wise: CREATE TABLE info.EducationTypes ( ID INT NOT NULL PRIMARY KEY, Name NVARCHAR(64) NOT NULL, FKParentID INT NULL REFERENCES info.EducationTypes(ID) ) the idea is to have a class hierarchy like the following one: public abstract class EducationType { public int ID { get; set; } public string Name { get; set; } } public

Placement of DTO / POCO in a three tier project

人盡茶涼 提交于 2019-12-30 10:31:12
问题 I've been in the process of re-writing the back-end for a web site and have been moving it towards a three-tiered architecture. My intention is to structure it so: Web site <--> WCF Service (1) <--> Business Layer (2) <--> Data Layer (3) My issue is with the placement of the DTO's within this structure. I'll need to use DTO's to move data between the business layer and the WCF service and from the WCF service to the consuming web site. During my research on here I've read some excellent

EF4 Code First - How to properly map Splitting an Entity Across Multiple Tables

帅比萌擦擦* 提交于 2019-12-30 09:39:15
问题 I am using EF4 CTP5 to try to persist a POCO object that is split among two tables, the link being the ContactID. When i save a contact, i want the core contact information saved in one table (Contacts), and the link to the user who owns the contact saved in another (UserToContacts). I have the custom mapping defined below, but when I SaveChanges, i get the following error: A value shared across entities or associations is generated in more than one location. Check that mapping does not split

How do I convert a datatable into a POCO object in Asp.Net MVC?

孤者浪人 提交于 2019-12-30 09:22:27
问题 How do I convert a datatable into a POCO object in Asp.Net MVC? 回答1: Pass each DataRow into the class constructor (or use getters/setters) and translate each column into the corresponding property. Be careful with nullable columns to extract them properly. public class POCO { public int ID { get; set; } public string Name { get; set; } public DateTime? Modified { get; set; } ... public POCO() { } public POCO( DataRow row ) { this.ID = (int)row["id"]; this.Name = (string)row["name"]; if (!(row

How do I convert a datatable into a POCO object in Asp.Net MVC?

瘦欲@ 提交于 2019-12-30 09:21:26
问题 How do I convert a datatable into a POCO object in Asp.Net MVC? 回答1: Pass each DataRow into the class constructor (or use getters/setters) and translate each column into the corresponding property. Be careful with nullable columns to extract them properly. public class POCO { public int ID { get; set; } public string Name { get; set; } public DateTime? Modified { get; set; } ... public POCO() { } public POCO( DataRow row ) { this.ID = (int)row["id"]; this.Name = (string)row["name"]; if (!(row

Entity Framework POCO SaveChanges() on Update doesn't work?

眉间皱痕 提交于 2019-12-29 04:47:28
问题 I'm working with EF CTP 4, using POCO models, adding a new object and call SaveChanges() works but updating the object doesn't work. Here's the code for update: public void UpdateContact(Contact contact) { var findContact = GetContact(contact.ContactID); findContact = contact; _context.SaveChanges(); } public Contact GetContact(int contactId) { return GetAllContacts().SingleOrDefault(c => c.ContactID == contactId); } public IQueryable<Contact> GetAllContacts() { return _context.Contacts; } I

Linq expressions and extension methods to get property name

坚强是说给别人听的谎言 提交于 2019-12-28 16:21:20
问题 I was looking at this post that describes a simple way to do databinding between POCO properties: Data Binding POCO Properties One of the comments by Bevan included a simple Binder class that can be used to accomplish such data binding. It works great for what I need but I would like to implement some of the suggestions that Bevan made to improve the class, namely: Checking that source and target are assigned Checking that the properties identified by sourcePropertyName and targetPropertyName

Linq expressions and extension methods to get property name

我的梦境 提交于 2019-12-28 16:21:09
问题 I was looking at this post that describes a simple way to do databinding between POCO properties: Data Binding POCO Properties One of the comments by Bevan included a simple Binder class that can be used to accomplish such data binding. It works great for what I need but I would like to implement some of the suggestions that Bevan made to improve the class, namely: Checking that source and target are assigned Checking that the properties identified by sourcePropertyName and targetPropertyName