value-objects

DDD Value Objects and Entity Without ORM Mapping in PHP

独自空忆成欢 提交于 2021-02-07 11:00:27
问题 First, as I know, Entity in DDD is almost same with Value Object except Entity has identity. Every article I have read say same thing that entity id has ORM mapping with any ORM tool. But I don’t want to use ORM mapping in Entity. Instead, I would like to do database operation with Repository Interfaces without mapping. And, in this case, I am stuck on how I should do this. I will explain in my mind with an example below Let’s assume I have a TODO application and there are some questions in

How can I create a Required Owned Type with Entity Framework Core 3.0

陌路散爱 提交于 2020-08-07 08:03:50
问题 I'm struggling creating a non-nullable/required Owned Type with Entity Framework Core. I'm using EF Core 3.0 against PostgreSQL database. My value object: public class PersonName { public PersonName(string name) { this.Name = name; } public string Name { get; set; } } My entity: public class Person { public int Id { get; set; } public virtual PersonName FullName { get; set; } } My entity configuration: public void Configure(EntityTypeBuilder<Person> builder) { builder.ToTable(nameof(Person));

How can I create a Required Owned Type with Entity Framework Core 3.0

泪湿孤枕 提交于 2020-08-07 08:03:11
问题 I'm struggling creating a non-nullable/required Owned Type with Entity Framework Core. I'm using EF Core 3.0 against PostgreSQL database. My value object: public class PersonName { public PersonName(string name) { this.Name = name; } public string Name { get; set; } } My entity: public class Person { public int Id { get; set; } public virtual PersonName FullName { get; set; } } My entity configuration: public void Configure(EntityTypeBuilder<Person> builder) { builder.ToTable(nameof(Person));

Entity Framework Core 2.1 - owned types and nested value objects

笑着哭i 提交于 2020-06-23 07:23:32
问题 I'm learning DDD and the tutorial I'm currently following is implemented using NHibernate, but since my lack of experience with it I've decided to go through the course using EF Core 2.1. However, I'm currently a bit stuck with the following: I have three classes Customer which is an entity and two value objects ( CustomerStatus and inside of it value object ExpirationDate ) - like this: public class Customer : Entity { //... constructor, other properties and behavior omitted for the sake of

How to store value objects in a relational database?

我怕爱的太早我们不能终老 提交于 2020-01-14 03:18:08
问题 I am working with a large project that has many objects that represent simple (non-related) values. Sometimes these values are a single string, sometimes they are two strings, sometimes a string and an int... Currently we have a 'values' table in our relational database that contains the columns: Id , Category , String1 , String2 ..., Int1 , Int2 ..., Double1 etc. It's convenient, but a mess. The values all have the following properties: Every object with the same Category has the same

How to store value objects in a relational database?

孤人 提交于 2020-01-14 03:17:26
问题 I am working with a large project that has many objects that represent simple (non-related) values. Sometimes these values are a single string, sometimes they are two strings, sometimes a string and an int... Currently we have a 'values' table in our relational database that contains the columns: Id , Category , String1 , String2 ..., Int1 , Int2 ..., Double1 etc. It's convenient, but a mess. The values all have the following properties: Every object with the same Category has the same

EF 6: mapping complex type collection?

若如初见. 提交于 2020-01-13 09:59:05
问题 Does EF 6 (code first) supports complex type collection(Value Object collections) mappings? I know that it supports Complex types, but haven't still found an example where we have a collection of complex types. For instance, suppose you have an entity called Student, which has a collection of contacts. With NH, I can simply say that Student has a collection of contacts and that contact is a component (equivalent to complex type in ef). Can this be done with EF without changing contact to an

Might EnumMap be considered a reasonable alternative to Java beans?

懵懂的女人 提交于 2020-01-04 06:00:37
问题 Curious if anybody has considered using EnumMap in place of Java beans, particularly "value objects" (with no behavior)? To me it seems that one advantage would be that the name of a "property" would be directly accessible from the backing Enum, with no need for reflection, and therefore I'd assume it would be faster. 回答1: It may be a little faster then using reflection (I didn't measure it, didn't find any metrics in Google either); however there are big disadvantages to this approach: You

DDD: what's the use of the difference between entities and value objects?

你。 提交于 2020-01-01 05:20:14
问题 Entities and value objects are both domain objects. What's the use of knowing the distinction between the two in DDD? Eg does thinking about domain objects as being either an entity or value object foster a cleaner domain model? 回答1: Yes, it is very helpful to be able to tell the difference, particularly when you are designing and implementing your types. One of the main differences is when it comes to dealing with equality, since Entities should have quite different behavior than Value

Null value objects in NHibernate

假如想象 提交于 2019-12-22 03:45:38
问题 I have a person entity containing an Address as a value object: public Person() { WithTable("Person"); Id(x => x.Id); Component<Address>(x => x.Address, a => { a.Map(x => x.Address1); a.Map(x => x.Address2); a.Map(x => x.Address3); a.Map(x => x.Town); a.Map(x => x.Postcode); }); } It states in the NHibernate docs that if all the properties of a value object (Address1, Address2 etc) are null, the entire component will be mapped as null (i.e. Person.Address will be null). This is giving me