I'm beginning a new project and I want to start by modeling the data that the client needs to store. However, I have no idea where to begin. So far, I'm trying to model two simple entities, Event
and Address
. An Event
can have multiple Addresses
and an Address
can be associated with multiple Events
. This is what I have:
public class Event
{
public int Id { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public List<Address> Addresses { get; set; }
}
public class Address
{
public int Id { get; set; }
public string Street { get; set; }
public string Zip { get; set; }
public List<Event> Events { get; set; }
}
However, I ran into a problem when I tried to create the test repositories for these two objects. They have a circular dependency: Event
can't populate its Addresses
list until Address
is fully populated, but Address
can't populate its Events
list until Events
is fully populated. This led to me to believe that I don't know what I'm doing.
I've been reading a lot about POCO, DTO, DAO, and DDD, but these concepts don't make much sense to me no matter how hard I try to understand them. I've only recently graduated from college and I haven't even heard of the term 'domain model' until a week ago.
Conceptually, what I'd like to do is first create classes that represents the types of data I need to store (the Entities
I believe). These classes will also contain the validation logic (is this POCO?). After that, I want to set up repositories to access collections of these objects and populate any relationships they may have (for example, Event
will get populated with a list of Addresses
) [is this persistence ignorance?]. Only after all that's in place do I want to create the database to hold the data (through a DAO? Is a ORM a DAO? How would I use LINQ-To-SQL to do this?). And where does IoC fit into all of this, or does it not fit at all if I know that my backend will never change and I will always hit up only one database?
If it hasn't been obvious already, I'm pretty confused as to where I'm supposed to start. I have a good conceptual idea of what I want to do, I just have no idea how to implement it. Can someone provide me with advice on a good starting point? Thanks.