Trimming an Entity ?

Posts   
 
    
graphicsxp
User
Posts: 7
Joined: 14-Aug-2008
# Posted on: 14-Aug-2008 11:42:25   

Hello,

My .net class is meant to return an Entity to my client (which is a Flex application). The client only expects the fields of my Entity that are in my database's table. But the problem is that the Entity contains LOADS of extra-fields which are completely irrelevant to the client application, such as AuditorToUse, AuthorizerToUse, BuildInValidationByPassMode, a fields property, a FieldsCustomProperties, etc, etc.....

I'm not going to list them all here but there are quite a few. So how can I return an Entity that would contain only the fields I'm interested in (basically the one coming from my database's table)

thanks

Walaa avatar
Walaa
Support Team
Posts: 14994
Joined: 21-Aug-2005
# Posted on: 14-Aug-2008 12:18:34   

Using v.2.5 you can serialize an entity to an XML which is stripped out of all the un-needed data.

Also you might consider sending a DTO, and there are some templates available in the forums for generating the DTOs.

graphicsxp
User
Posts: 7
Joined: 14-Aug-2008
# Posted on: 14-Aug-2008 12:22:52   

Walaa wrote:

Using v.2.5 you can serialize an entity to an XML which is stripped out of all the un-needed data.

Also you might consider sending a DTO, and there are some templates available in the forums for generating the DTOs.

Thanks for the swift answer.

Sending XML is excately what I DON'T want to do ! however the DTO sounds good. I'll take a look at that.

graphicsxp
User
Posts: 7
Joined: 14-Aug-2008
# Posted on: 14-Aug-2008 12:40:53   

I can't seem to find the Template tool in 2.6. Where can I find it ?

Also, I believe I'm going to run into the same issue as this thread: http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=10435&HighLight=1

I want to do exactely the same thing, which is creating a DTO that might contain another DTO, and send that to a Flex client. Is there an elegant way for doing so ?

Walaa avatar
Walaa
Support Team
Posts: 14994
Joined: 21-Aug-2005
# Posted on: 14-Aug-2008 13:46:31   

DTO's are meant to be used to be a one level containers of data.

IMHO, you may try the following:

Create your own templates to generate "DTO-like" custom entity classes without the unneeded properties. (These should be generated side by side with the usual EntityClasses).

In your business logic you may xml serialize the original entities and then deserialize them back to the custom classes, which then can be wired out.