poco

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

橙三吉。 提交于 2019-12-01 04:41:14
How do I convert a datatable into a POCO object in Asp.Net MVC? 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["modified"] is DBNull)) { this.Modified = (DateTime)row["modified"]; } ... } } A data table typically holds

Entity Framework & Self-Tracking Entities vs POCO

北城以北 提交于 2019-12-01 04:32:24
问题 If i'm wanting to use entity framework 4 as my data layer and want to send my entities to another tier whether it be via WCF or another mechanism and then want the ability to update the entities and send them back for updating/deleting/inserting is it best to use self-tracking entities or poco objects? I'd rather use POCO objects if possible because i don't want to depend on the entity framework in the other layers if possible but i don't know how difficult it is to reconnect POCOs to the

Where is EntityConfiguration and ContextBuilder in Visual Studio 2010?

删除回忆录丶 提交于 2019-12-01 04:13:29
I see examples about code-only POCO for en entity framework 4, but I cannot find the classes EntityConfiguration and ContextBuilder and I cannot see which reference I need to add to have them. Is it part of the .Net Framework 4 or do we have to download something else? The POCO stuff you're looking for is in a separate download. Current version is at http://www.microsoft.com/downloads/details.aspx?FamilyID=af18e652-9ea7-478b-8b41-8424b94e3f58&displayLang=en Once you run the installer, you'll need to grab the Microsoft.Data.Entity.CTP.dll file (mine was in the C:\Program Files\Microsoft ADO.NET

Entity Framework Stored Procedures and POCO

拥有回忆 提交于 2019-11-30 23:09:24
I need advice on using stored procedures with Entity Framwork 4.x to return data into POCO objects. I don't want to have to copy the data from an entity object to a POCO object. I want to execute a stored proc and have the data loaded directly into my POCO class. Is there a way to do this? Do I need some sort of mapping like you would use in Nhibernate? If so, could this mapping be attribute based? Edit: Using Justin's help below, I found that the way to do this is: SqlParameter p1 = new SqlParameter("@p1", "xxxx"); SqlParameter p2 = new SqlParameter("@p2", "yyyy"); SqlParameter[] parameters =

How to get around “Internal .NET Framework Data Provider error 1025.”?

 ̄綄美尐妖づ 提交于 2019-11-30 21:33:06
I am using the Entity Framework 4.3, POCO, database first and I am getting the following error: Internal .NET Framework Data Provider error 1025. QUESTION: I think that my query expresses my intent but I seem to be hitting this error, so I am wondering if anyone knows how I could structure my query differently to get around this error? Here is the scenario... I have a SQL server 2008 database that has 2 tables - A and B: A AId (int - not null - identity - primary key) AName (nvarchar(10) - not null) B BId (int - not null - identity - primary key) SomeName (nvarchar(10) - not null) AId (int -

Using ADO.net Entity Framework 4 with Enumerations? How do I do it?

流过昼夜 提交于 2019-11-30 19:22:37
Question 1: I am playing around with EF4 and I have a model class like : public class Candidate { public int Id {get;set;} public string FullName {get;set;} public Gender Sex {get;set;} public EducationLevel HighestDegreeType {get;set;} } Here Gender and EducationLevel are Enums like: public enum Gender {Male,Female,Undisclosed} public enum EducationLevel {HighSchool,Bachelors,Masters,Doctorate} How do I get the Candidate Class and Gender and EducationLevel working with EF4 if: I do model first development I do db first development Edit: Moved question related to object context to another

Entity Framework Stored Procedures and POCO

99封情书 提交于 2019-11-30 18:06:13
问题 I need advice on using stored procedures with Entity Framwork 4.x to return data into POCO objects. I don't want to have to copy the data from an entity object to a POCO object. I want to execute a stored proc and have the data loaded directly into my POCO class. Is there a way to do this? Do I need some sort of mapping like you would use in Nhibernate? If so, could this mapping be attribute based? Edit: Using Justin's help below, I found that the way to do this is: SqlParameter p1 = new

Serialize to XML - private properties

二次信任 提交于 2019-11-30 18:03:53
问题 I'm looking for a way to serialize a POCO that contains some read-only properties. In some Google and StackOverflow searches, I've seen the following suggestions: use DataContractSerializer ; or use SoapFormatter or BinaryFormatter ; or replace my readonly properties by read/write properties ; My classes are very simple, they look like: public class MyClass { public int Id { get; private set; } public string Name { get; private set; } public MyClass(int id, string name) { Id = id; Name = name

how to manage _id field when using POCO with mongodb c# driver

久未见 提交于 2019-11-30 11:49:47
问题 If I want to read and write mongo data with a POCO public class Thingy { public string Foo {get;set;} } ... coll.Insert(new Thing(Foo = "hello")); When I read back I get a failure saying that _id is an unexpected attribute (which it is). So then I added a field called _id to the class. Now the insert doesnt work saying that the _id field cannot be null. A tried BsonIgnoreIfNull attribute, that didnt work. 回答1: When you insert an object, if it doesn't have an _id field then the driver adds one

How should I structure a simple ASP.NET MVC app?

女生的网名这么多〃 提交于 2019-11-30 07:03:53
I've been reading a few things about ASP.NET MVC, SOLID and so on, and I am trying to figure out a simple "recipe" for small-to-medium ASP.NET MVC apps that would put these concepts together; the issue that I am most concerned with is ending up with controllers that are too complex and being like code-behind files in webforms, with all type of business logic into them. I am considering the following architecture, for a small data-driven app: Controllers: only handle requests, call an appropriate service and return the action result to the View; Models: POCO, handle all the business logic,