poco

is it possible to share POCO object between two DbContext?

痴心易碎 提交于 2019-12-11 16:32:25
问题 I have some POCO classes which can generally divided into two groups, for example: public class Student { public Student() { this.Courses = new List<Course>(); this.Clubs = new List<Club>(); } public int Id { get; set; } public virtual ICollection<Course> Courses { get; set; } public virtual ICollection<Club> Clubs { get; set; } } and corresponding Course and Club classes, and they all have their own relationships to other classes. The problem is, those two groups are big, they both contains

Adding attributes to POCO properties for mapping x,y cells

牧云@^-^@ 提交于 2019-12-11 14:37:40
问题 public class MyClass { public string MyProperty{ get; set; } Now, I would like to Map each property to have an [X, Y] integer. MyProperty = "Its string value."; MyProperty.X = 4; MyProperty.Y = 10; There are a couple of ways I am thinking about doing this, but not sure what would be the best. Basically mapping a POCO to an Excel spreadsheet. Should I or can I decorate the properties? Should I use a Dictionary? 回答1: As @DavidHoerster mentioned, you need a more descriptive class model: public

Entity Framework POCO with Foreign keys

一个人想着一个人 提交于 2019-12-11 05:26:17
问题 My question can better be explained via example code. I am using POCO with change tracking proxies that is generated by the C# POCO generator by default. Please see below. Assume you have Movie, MusicDirector and Director in the database and the relationship between them is a Director & MusicDirector can direct multiple movies and a movie can have only one Director and MusicDirector. Since I am a new user and cannot post images, here is my db structure. Movie table has MovieId, Name

How do I query many-to-many mapping in EF4?

孤街浪徒 提交于 2019-12-11 04:23:37
问题 I have a pretty simple problem with a not-so-obvious solution. I have a relational mapping in my database between Users and Roles, and each user can be mapped to one or more roles. So the mapping is like so: User < 1:n > UserRole < n:1 > Role In my generated EF4 POCOs, User and Role each have an ICollection of the other: public class User { //Bunch of other properties/methods public virtual ICollection<Role> Roles } public class Role { //Bunch of other properties/methods public virtual

XML Schema Definition Tool not generating SchemaLocation

℡╲_俬逩灬. 提交于 2019-12-11 01:52:26
问题 Does the xsd.exe tool provided with Visual Studio generate the SchemaLocation attribute (in the xs:import) when generating XSDs from plain old C# objects? I am finding that my XSDs that were generated are not valid because the xs:import will import a namespace and not provide the relative schemalocation value prompting the below Imported Schema for namespace 'urn:company-event-namespace' was not resolved. 回答1: As you've found, it does not generate that attribute. This may have to do with the

scaffolding viewmodels based on database tables

纵然是瞬间 提交于 2019-12-11 01:36:59
问题 Is there anything that would aid us in designing/scaffolding View models from SQL Server database tables but would result in very lean classes? I know something like that exists for Rails, maybe there's something similar in ASP.NET MVC? I like what EF wizard creates but it's too heavy - too much attributes, constraints, events and everything is attached to the entities so you can't actually use them as View models (actually you can but it quickly becomes a pain). 回答1: I think you could use a

Schema specified is not valid. Errors: The relationship not loaded because the type is not available

风格不统一 提交于 2019-12-11 00:34:46
问题 I have the entities Dependency, Product and Access. Dependency is connected to Product and Access. When i try to create a object set of Access with: this.context.CreateObjectSet<Access>(); It's working... but when i try to create a object set of Product i get this error: Schema specified is not valid. Errors: The relationship 'Model.FK_Product_Dependency' was not loaded because the type 'Model.Dependency' is not available. Any ideas? OBS: i'm working with Database to Model, and with EF 4.0

What constitutes a rich domain model in a POJO/POCO?

牧云@^-^@ 提交于 2019-12-10 16:48:04
问题 What is the difference between A simple fields-accesors-mutators class A rich-modeled class What constitutes rich modeling in business-domain classes? 回答1: "Rich" as used here implies "rich behavior" (as opposed to state). There is technical behavior and domain behavior. Accessors and mutators are technical; they lack the "why" which defines business interest. Domain objects represent the "why" and encapsulate the "how". Actually, all objects do that; domain objects do it specifically for

EF4: Difference between POCO , Self Tracking Entities , POCO Proxies

◇◆丶佛笑我妖孽 提交于 2019-12-10 15:12:11
问题 Can someone point me the difference between POCO , Self Tracking Entities , POCO Proxies? Actually, I am working Entity Framework 4.0 and POCO(Repository Pattern) and whenever I do some changes in the POCO and call ObjectContext.Savechanges then it reflects to the DB. My question is, How does the Context persist the change to the DB since it is not tracked? Does the Context generates the tracking info on the fly for POCO? Sample Code I am using, IEFRepository<Category> catRepository = new

Easiest way to serialize and store objects in c#?

不打扰是莪最后的温柔 提交于 2019-12-10 14:27:27
问题 Im looking for a simple solution to serialize and store objects that contain configuration, application state and data. Its a simple application, its not alot of data. Speed is no issue. I want it to be in-process. I want it to be more easy-to-edit in a texteditor than xml. I cant find any document database for .net that can handle it in-process. Simply serializing to xml Im not sure I want to do because its... xml. Serializing to JSON seems very javascript specific, and I wont use this data