Reputation: 9648
I have one table with 20 columns, I want only display this data on UI (not add/edit/delete). I want to know, where is appropriate place to create DTO class for this table, in DAL project or in Web project?
Upvotes: 0
Views: 762
Reputation: 1447
If you only wants to show data, the better approach would be the create a View and directly get it on Client Side. This will be much more cleaner and easier.
Upvotes: 0
Reputation: 8232
If you are using LINQ to Entities or LINQ to SQL, you could use projection to limit what is returned from the WCF service request and work with an anonymous type. Use the LINQ select method. Then you wouldn't have to create a DTO object.
If the UI you mentioned is Silverlight, WCF Data Services (EDIT: and WCF RIA Services does not) support projection across a service.
LINQ example:
context.Displays
.OrderBy(d => d.Title)
.Select (
d =>
new
{
Title = d.Title
})
Julie Lerman says to use the QueryView in an MSDN Magazine article. That might be the solution.
Upvotes: 0
Reputation: 9478
You can create DTO's in the web project, map the entity to it, and have the domain service call return it. You could also just return the entity and mark the Properties you don't want displayed with [Display(AutoGenerated = False)].
Upvotes: 3