views:

118

answers:

1

I have a domain interface

public interface ITicket
{
...
TicketWorkflowStatus StatusId{get;set;} // Enum
}

but the linq-to-sql persistance layer on the database wants to use int, can I change it in the dbml so that the local type is TicketWorkflowStatus? What are my options?

A: 

Domain is supposed to be detached from persistence infrastructure and there are no excuses that this infrastructure can force such a decisions when modeling Your domain model.

You might find useful this article. In Your case it's external coupling.

Telling from experience - once You start to serve too much to Your ORM, it will bring down You to knees in no time.

Arnis L.
in what way is my domain not detached from persistence? persistance can be attached/dependent on the domain, so I'm not sure what you are getting at here?
Maslow
@Maslow E.g. - i think it's 99% that you chose to abstract Your domain entities using interfaces because of linq to sql, right? That's a decision ORM tricked You into. That's an implicit dependency. While technically persistence is detached, in reality it is not at all.
Arnis L.
well no, I chose to put interfaces on my domain, so that any other layer can implement a DTO and the mapping code is T4 generated. So that the user of the T4 can decide if data coming from the db should be routed through business layer validation or passed right back to presentation. A DTO can live in presentation and be passed into business for validation, then the validated business object can be passed into the persistence layer. Then if needed the persistence layer can use the same mapping methods to push into the persistence objects those business objects.
Maslow
Isn't that external coupling? Your presentation, business and persistence layer uses same interface that defines shape of your entity. Isn't that correct?
Arnis L.
Actually - I've seen this situation before on project co-workers work on. Mark Your TicketWorkflowStatus as enum that explicitly inherits from int. Like `public class enum TickedWorkflowStatus : int`. That could be quickest way to solve problem (unless I'm wrong).
Arnis L.