Print Page | Close Window

Exclude Attribute

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2010
Forum Discription: For .NET 4.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=3548
Printed Date: 07-May-2025 at 12:33pm


Topic: Exclude Attribute
Posted By: gregweb
Subject: Exclude Attribute
Date Posted: 18-Jul-2012 at 11:28am
Is there an attribute that can be set on a field so that it does not ever get downloaded to the client?

I have a field which is fairly large and used only for searching, so it doesn't need to get sent down to the client. I do need to be able to populate it on the server however.

Greg



Replies:
Posted By: DenisK
Date Posted: 18-Jul-2012 at 12:08pm
Hi Greg,

There is. The attribute is called IgnoreDataMember ( http://msdn.microsoft.com/en-us/library/system.runtime.serialization.ignoredatamemberattribute.aspx - http://msdn.microsoft.com/en-us/library/system.runtime.serialization.ignoredatamemberattribute.aspx )

We also have a couple of suggestions that we recommend before going the attribute route.

1. You can create a subset of the entity, excluding the fields that you don't want to send to the client.

2. Or you can create a secondary entity with the excluded fields and create a 1 to 1 relation with the main entity. This is such that when you query for the main entity, you have an option to exclude that secondary entity.

Hope this helps.



Print Page | Close Window