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

3 posts, 0 answers
  1. Norbert
    Norbert avatar
    35 posts
    Member since:
    Dec 2009

    Posted 03 Oct 2011 Link to this post

    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. Norbert
    Norbert avatar
    35 posts
    Member since:
    Dec 2009

    Posted 03 Oct 2011 Link to this post

    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
  3. DevCraft banner
  4. Serge
    Admin
    Serge avatar
    375 posts

    Posted 06 Oct 2011 Link to this post

    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 >>

Back to Top