poco

Is my understanding of POCO's + Entity Framework v4, correct?

我们两清 提交于 2019-12-06 05:44:43
can someone please confirm/correct me, with my understanding of using POCO's with the Entity Framework v4? If I'm going to want to use POCO's with my EF4 context, do I still need to place/create ENTITIES on the designer/.edmx ? Isn't the idea of using POCO's so I don't need to use those 'heavy' entities? or do i still need those entities, it's just that somewhere else I actually move the data out of the entities and into my POCO's .. which is what gets used by any consuming code? If you want to use POCO you have three choices: First choice is to create EDMX model. In EDMX you will turn off

Using FluentValidation with Castle Windsor and Entity Framework 4.0 (POCO) in MVC2

喜夏-厌秋 提交于 2019-12-06 05:13:20
This isn't a very simple question, but hopefully someone has run across it. I am trying to get the following things working together: MVC2 FluentValidation Entity Framework 4.0 (POCO) Castle Windsor I've pretty much gotten everything working. I have Castle Windsor implemented and working with the Controllers being served up by the WindsorControllerFactory that is part of MVCContrib. I also have Castle serving up the FluentValidation validators as is described by this article: http://www.jeremyskinner.co.uk/2010/02/22/using-fluentvalidation-with-an-ioc-container/ My problem comes in when I try

Poco学习(二)

我的梦境 提交于 2019-12-06 04:41:27
1. Poco::JSON /////////////////// POCO::JSON ///////////////////// #include "Poco/JSON//Parser.h" #include "Poco/Dynamic/Var.h" #include <fstream> void CreateJson() { Poco::JSON::Object root, temp; Poco::JSON::Array province, cities; // 1. //对中文的支持不好 cities.add("大庆"); cities.add("哈尔滨"); temp.set("name", "黑龙江"); temp.set("cities", cities); province.add(temp); cities.clear(); temp.clear(); cities.add("深圳"); cities.add("广州"); temp.set("name", "广东"); temp.set("cities", cities); province.add(temp); root.set("province", province); root.set("country", "中国"); std::ostringstream osstr; root.stringify

C# Entity Framework should we set a relationship by using the POCO.Id or just the POCO?

落爺英雄遲暮 提交于 2019-12-06 03:42:36
I have a situation in a service method where assigning a POCO as a child object of another POCO does not work as expected. I am using Entity Framework 4. public void ChangeOrderCurrency(Currency currency) { order.CurrencyId = currency.Id; order.Currency = currency; // other stuff related to exchange rates etc } Which is more correct to use to set the relationship? order.CurrencyId = currency.Id or order.Currency = currency ? In this current code which passes all unit tests, occasionally the line order.Currency = currency will set both order.CurrencyId and order.Currency to NULL It makes more

Deserialize nested JSON Response with RestSharp Client

ⅰ亾dé卋堺 提交于 2019-12-05 21:12:35
I'd like to consume a REST Api and deserialize the nested JSON Response. For that purpose I tried to create some POCO classes which represent the JSON Response [1]. The response looks like this: { "success": true, "message": "OK", "types": [ { "name": "A5EF3-ASR", "title": "ITIL Foundation Plus Cloud Introduction", "classroomDeliveryMethod": "Self-paced Virtual Class", "descriptions": { "EN": { "description": "some Text null", "overview": null, "abstract": "Some other text", "prerequisits": null, "objective": null, "topic": null } }, "lastModified": "2014-10-08T08:37:43Z", "created": "2014-04

LINQ to XML to POCO object

六月ゝ 毕业季﹏ 提交于 2019-12-05 21:01:14
I've got an XML file that I want to turn in to a list of POCO objects. I have the following working code to read the XML and create objects from it. I just want to check this is a good way to do this and I'm not missing any tricks. In particular with regards to the nested Linq query. XDocument xmlDoc = XDocument.Load(path); var q = from file in xmlDoc.Descendants("File") select new ImportDefinition() { Name = file.Attribute("Name").Value, TypeName = file.Attribute("TypeName").Value, ColumnMappings = ( from map in file.Descendants("ColumnMap") select new ColumnMap() { DatabaseColumn = new

Convert POCO object to Proxy object in EntityFramework

蓝咒 提交于 2019-12-05 15:05:55
I have a MVC3 Project and I have run into a problem. I have a Create controller which takes as a parameter one of my POCO objects. I add this object to the database like this: entity = dbSet.Add(entity); After this method returns, I would like to use the lazy loading features of the object. Unfortunately the object is not a Proxy object generated by the EntityFramework...Is there a way to somehow solve this? Thank You, AFrieze The entity must be already proxied when you pass it to Add method. Add method will not return another instance of the class and you cannot change the type of the

multiple cascade delete path in many-many relationship (EF 4.1)

北战南征 提交于 2019-12-05 08:48:24
THE TABLES: Shop Product Category THE RELATIONSHIPS: (Shop) 1 <---> n (Categories) (Shop) 1 <---> n (Products) (Categories) n <---> n (Products) THE CASCADE DELETES: Shop ---> Categories ... I defined this using fluent API Shop ---> Products ... I defined this using fluent API Categories <---> Products ... EF 4.1 automatically defines cascade for "Category_Product" join table THE PROBLEM: Above results in a "multiple" cascade deletion path exception. POTENTIAL FIXES: Remove the ManyToManyConvention, but that means I must manually perform deletes for every join table in the system, which is

POCO Class in EF not working as Expected

给你一囗甜甜゛ 提交于 2019-12-05 07:24:47
I have created a DataBase in SQL and created an EDMX in Visual Studio 2012. It automatically created POCO (TT) classes. Everything looks fine. Now I change the column name of a table. I update the EDMX. Opening the EDMX in XML and everything looks fine. Question 1 After I ran Custom tool in TT, I see that a new property got created additionally, e.g.: SQL table name : Student Column name : sName In my POCO Class public int sName{ get; set; } got automatically created. Now I change the column name in SQL to Column name : studentName My POCO class public int sName{ get; set; } public int

Do we need DataContract attribute on POCO classes in Ado.net entity Framework 2010

妖精的绣舞 提交于 2019-12-05 06:07:54
问题 I read somewhere in stackoverflow itself that when we use POCO classes for WCF contracts using Poco generator , we need not use DataContract and DataMember attributes.WCF do it auto for you? . I don't know how it manages this. I created a sample application without using these attributes and I was able to generate those entities on client side and use them. I disabled proxy generation and Lazy loading. Am i missing anything here.? Is there really no need of putting these attributes. 回答1: You