Entity objects over SOAP

Posts   
 
    
Chris_HBOS
User
Posts: 2
Joined: 25-Jul-2005
# Posted on: 25-Jul-2005 10:41:51   

Hi Folks,

I'm an LLBLGenPro newcomer, currently evaluating it for use on a big Bank project here in the UK.

I was wondering if there's a way to develop "lite" entity classes so as just to contain the data for the object ( not even the rest of the objects if there's a graph )?

Also I'd prefer my SOAP client not to be exposed to LLBLGenPro classes at all, and I want to try and cut down the size of the SOAP message to be as efficient as possible.

I'm guessing this would either be a new template, or modification to the existing SD_EntityTemplate?

Sorry if this is an FAQ - I did scan through the help, website and forums but didn't find anything.

Cheers,

  Chris
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 25-Jul-2005 12:44:29   

If you want to send them over remoting, and you want a very tiny packet, you should design a small class and copy the data over, generate the code for that using a template indeed. the thing is though that the receiving end of the entity has to be able to track changes as well, so if the data is altered there and send back, the changes tracked should be propagated as well. This is done in the regular entity (you can even save field values etc.) and if you do it yourself you probably lose that info. Without that info, the data can't be saved on the server.

Frans Bouma | Lead developer LLBLGen Pro
Posts: 497
Joined: 08-Apr-2004
# Posted on: 25-Jul-2005 12:59:22   

We do this simple_smile

We have a template that generates a "business entity" for each LLBL entity. The benefits are that its easy to add extra properties by inhertinting these classes. If you want to add extra properties to the generated entities, then quite a lot of fiddling is required - (it was a while ago though, this might have changed since?)

Anyway, as Frans says, theres downsides to this - and quite a few - in that you lose all the extra validation code and other goodies. And when you pass the entity back to the BLL, for example to an Update method, you need to put the values from the simple entity back into a LLBL entity, to enter it into the database rage

If you're interested I can post the template code?

Chris_HBOS
User
Posts: 2
Joined: 25-Jul-2005
# Posted on: 25-Jul-2005 13:08:27   

Thanks for both responses. Yeah I can see what you're saying.

Luckily my use cases are query / read-only for now, so it's unlikely I'll have to reconstruct my LLBL entity server-side from the "lite" entity for persisting.

Matt - would be interested to see the template you came up with. Much appreciated!

Cheers,

 Chris
Posts: 497
Joined: 08-Apr-2004
# Posted on: 25-Jul-2005 14:53:15   

Very simple, you will probably want to modify this, but my simple template looks like this.


using System;
using System.Collections;

namespace BusinessEntities
{

    
    // Creation of the "Business Entities"
    

    /// <summary> 
    /// The <[CurrentEntityName]> business entity class.
    /// </summary>
    
    public class <[CurrentEntityName]>BusEnt
    {
    
    <[Foreach EntityField]>
        private <[TypeOfField]> _<[EntityFieldName]>;
    <[NextForeach]> 
    
    <[Foreach EntityField]>
        /// <summary>
        /// The <[EntityFieldName]> property of the Entity <[CurrentEntityName]>
        /// </summary>
        public virtual <[TypeOfField]> <[EntityFieldName]>
        {
            get
            {
                return (<[TypeOfField]>) _<[EntityFieldName]>;
            }
            set
            {
                _<[EntityFieldName]> = value;
            }
        }
    <[NextForeach]> 
    
    
    // 1:M or M:M - Represent a relationship to a collection.
    <[Foreach RelatedEntity OneToMany]>
        public ArrayList Related<[RelatedEntityName]>Array; //OneToMany
    <[NextForeach]> 
    <[Foreach RelatedEntity OneToOne]>
        public ArrayList Related<[RelatedEntityName]>Array; // OneToOne
    <[NextForeach]> 
    
    // 1:1 or M:1 - Represent a single entity
    <[Foreach RelatedEntity ManyToMany]>
        public <[RelatedEntityName]>BusEnt Related<[RelatedEntityName]>;  // ManyToMany
    <[NextForeach]> 
    <[Foreach RelatedEntity ManyToOne]>
        public <[RelatedEntityName]>BusEnt Related<[RelatedEntityName]>;  // ManyToOne
    <[NextForeach]> 
    
    }   
}

It exposes all fields as properties, and also adds an arraylist for the storing of related collections, which you can just ditch if you dont want this.

Have fun simple_smile