This is a migrated thread and some comments may be shown as answers.

Why you're using DTO's in SDK samples?

2 Answers 70 Views
Getting Started
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Norbert
Top achievements
Rank 2
Norbert asked on 03 Oct 2011, 03:06 PM
Hello,

in the SDK sample of OpenAccess you are using Dto's and the classes which are generated by OpenAccess.
Is there a special reason for that? Because they look very similar...?!
The following code is a part from your SDK so you know wahat I mean.

namespace SofiaCarRentalDAL
{
    public partial class CarRepository : IRepository<Car, CarDto>
    {
        private SofiaCarRentalEntityDiagrams context;
         
        public SofiaCarRentalEntityDiagrams Context
        {
            get
            {
                if (this.context == null)
                {
                    this.context = new SofiaCarRentalEntityDiagrams();
                }
                return this.context;
            }
        }
         
        public CarDto FindSingle(Expression<Func<Car, bool>> expression)
        {
            if (expression == null)
            {
                expression = (x) => true;
            }
            Car oaObj = this.Context.GetAll<Car>().Where(expression).FirstOrDefault();
         
            return GetDto(oaObj);
        }

Thanks in advance
Norbert

2 Answers, 1 is accepted

Sort by
0
Norbert
Top achievements
Rank 2
answered on 03 Oct 2011, 03:21 PM
Sorry, I've seen that you hosted the service layer via WCF. So is there no possibility to create the domain model within a WCF DataMember?

regards
Norbert
0
Serge
Telerik team
answered on 06 Oct 2011, 01:44 PM
Hi Norbert,

 The OpenAccess generated classes are further enhanced during compile time and handle a lot of operation regarding change tracking internally. They are packed with functionality and are not recommended for sending over the wire (using services). 

This is why we generate a set of similar DTO classes that in turn can be sent/serialized by the WCF. We also have easier time setting WCF attributes on these classes. 

As a matter of fact we are currently revamping the example you are looking at (I assume that is the WCF Plain service example). We will be providing an improved service layer that allows for all kinds of customizations. This will be part of the Q3 release. 

I hope this is helpful. 

Regards,
Serge
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's SQL Server Community Awards. We are competing in TWO categories and every vote counts! VOTE for Telerik NOW >>

Tags
Getting Started
Asked by
Norbert
Top achievements
Rank 2
Answers by
Norbert
Top achievements
Rank 2
Serge
Telerik team
Share this question
or