poco

converting POCO entity to business entity

て烟熏妆下的殇ゞ 提交于 2019-11-27 04:32:51
问题 I am willing to integrate the entity framework as my data layer. I followed articles and generated poco entities using this tutorial: http://blogs.msdn.com/b/adonet/archive/2010/01/25/walkthrough-poco-template-for-the-entity-framework.aspx I have my own business objects. Here is my business object Brach: public class Branch { public long BranchId { get; private set; } public string BranchName { get; set; } public string BranchCode { get; set; } public Branch() { } public void InsertBranch

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

ε祈祈猫儿з 提交于 2019-11-27 04:00:59
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 create a entity with the same key, attach it to the graph, then do ApplyCurrentValues . But this only

How to map table splitting in EF Code First?

故事扮演 提交于 2019-11-27 02:01:32
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. 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 the key in both entities. Also, include navigation properties in each entity pointing to the other entity. In

What is the best practice for sending data to the client: POCO or DTO?

爷,独闯天下 提交于 2019-11-27 01:53:27
问题 I'm starting a project using EF 4 and POCO. What is the best practice for sending data to the client ? Should I send the POCO or I should have a DTO instead? Are there any issue I should be aware of when sending the entity (that is disconnected from the context) to the client ? Is it a recommended practice to send the POCO to the client layer? 回答1: For me, one of the main reasons to use EF4 with POCO is the fact that you don't need DTO's. I can understand using DTO's with traditional EDMX

Exclude a field/property from the database with Entity Framework 4 & Code-First

旧巷老猫 提交于 2019-11-27 01:01:08
I will like to know that is there a way to exclude some fields from the database? For eg: public class Employee { public int Id { get; set; } public string Name { get; set; } public string FatherName { get; set; } public bool IsMale { get; set; } public bool IsMarried { get; set; } public string AddressAs { get; set; } } How can I exclude the AddressAs field from the database? In the current version the only way to exclude a property is to explicitly map all the other columns: builder.Entity<Employee>().MapSingleType(e => new { e.Id, e.Name, e.FatherName, e.IsMale, e.IsMarried }); Because

What does POCO mean? [duplicate]

前提是你 提交于 2019-11-26 22:38:19
问题 This question already has an answer here: 'POCO' definition 10 answers I have seen many articles about POCO. What is this? 回答1: Plain old CLR object 回答2: Based in the language you want to choose POCO means Plain Old CLR Object as Wikipedia mention or, Plain Old C++ Object as the PocoCapsule mentions it or, POrtable COmponents as the POCO Project mentions it. For what I'm concerned and for the reason of this question, and of course in simple words, it's a C++ library. :) The POCO C++ Libraries

How to serialize/deserialize simple classes to XML and back

狂风中的少年 提交于 2019-11-26 22:22:53
Sometimes I want to emulate stored data of my classes without setting up a round trip to the database. For example, let's say I have the following classes: public class ShoppingCart { public List<CartItem> Items {get; set;} public int UserID { get; set; } } public class CartItem { public int SkuID { get; set; } public int Quantity { get; set; } public double ExtendedCost { get; set; } } Let's say I build a ShoppingCart object in memory and want to "save" it as an XML document. Is this possible via some kind of XDocument.CreateFromPOCO(shoppingCart) method? How about in the other direction: is

EF POCO code only VS EF POCO with Entity Data Model

落爺英雄遲暮 提交于 2019-11-26 20:24:01
问题 The ability to separate domain objects completely from any kind of persistance code makes systems much more extensible and maintainable. Testing is made much easier when business logic can be tested separately from storage code. The use of POCOs with the Entity Framework (EF) is definitely a step in the right direction :) there are 2 types of using poco with EF 1.Using the entity designer 2.Using the code only which one is the best approach EF poco code first or EF Poco using the entity data

Explanation of POCO

倖福魔咒の 提交于 2019-11-26 20:14:34
问题 I'm wondering if anyone can give a solid explanation (with example) of POCO (Plain Old CLR Object). I found a brief explanation on Wikipedia but it really doesn't give a solid explanation. 回答1: Instead of calling them POCOs , I prefer to call them persistence ignorant objects . Because their job is simple, they don't need to care about what they are being used for or how they are being used. Personally I think POCOs are just another buzzword (like Web 2.0 - don't get me started on that) for a

What is the best way to instantiate and dispose DbContext in MVC?

北城以北 提交于 2019-11-26 19:23:24
问题 MVC 3 + EF 4.1 I'm choosing between two approaches to deal with DbContext: Instantiate in Application_BeginRequest , put it into HttpContext.Current.Items and dispose in Application_EndRequest . Create disposable UnitOfWork (kindof wrapper for DbContext ) and start each controller action with using(var unitOfWork = new UnitOfWork()) { ... } Share your experience please: Which one would you prefer? what are pros and cons for each approach? 回答1: I would suggest you use a Dependency Injection