Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

WCF and Attributes 1

Status
Not open for further replies.

Zyrenthian

Programmer
Mar 30, 2001
1,440
0
0
US
I am currently working with a WCF service and my searches both in this forum as well as on the web have no results specific enough to answer my question. Has anyone successfully passed attributes of a property via nettcp in WCF?

Here is the scenario. I have an attribute class with an ID field. This ID field is only used when I have a DB connection to allow faster queries to the DB for updates. At runtime, when I load my data to be passed over the wire, I use reflection to get me my attribute and set the ID field. I see it get set in on the server but when I access the same field on my client, the attribute is back to null.

I am thinking it is not possible. I am using .NET 3.5

Thanks,
Matt
 
I think that is correct. (de)serialization only works with the current object, not the decorations (attributes). when an object is serialized a new instance of the object is created along with new instances of any attributes. the properties/fields of this new instance are set.

any information I have read about messaging (NServiceBus, WCF, Rhino.Service.Bus, MassTransit) recommends keeping the message objects as POCOs (plain old compiled objects). no dependency injection, attributes, etc. after the object is serialized into an object again, map the object to a rich (dependency injection, attributes, etc) domain model.

you might be able to populate the attribute with a custom serializer/deserializer. but that seems like working harder, not smarter.

Jason Meckley
Programmer
Specialty Bakers, Inc.

faq855-7190
 
Thanks :) Hadn't heard the POCO's about WCF before but it will be worked into the design to prevent any further straying from the path.

Matt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top