views:

42

answers:

2

Hey, can anybody confirm the following scenario will work:

  • I am developing a 3-tier application in .NET 4.0: Winforms Client, aspx server and SQL 2008 database.
  • The server communicates with the SQL 2008 database by means of Entity Framework 4.0, and returns the entities in forms of STE's (in a separate assembly) to the client application over WCF.

Now I want to execute a stored procedure on the SQL server, which will return me a custom shaped dataformat (not a 1:1 mapping with an entity). I read that I could use complex types to hold the data this will return to me.

Now the question: will this complex type be serializable over WCF so the client can work with it too ? I suppose it is, but cannot seem to find a closing answer anywhere, and I wanna be sure before I proceed with my coding.

Thx !

TJ

A: 

Anything that can be represented in an XML Schema can be serialized and thus sent across the wire using WCF.

This includes all .NET basic primitive types like int, double, string, DateTime and any classes built from those.

Things that won't work are for instance:

  • any .NET specifics (like Exception, generics, ...) - remember, WCF is designed to be interoperable, not just between two .NET clients

  • anything with inherent behavior (like a Dictionary)

marc_s
You say generics aren't serializable over WCF ? However I am succesfully sending objects of type List<T> over (with T being an entity in my model). These are generics, right ? As I am in charge of both the server and client, there's no intention to support a non-.NET client. I know that's not entirely the vision of WCF, but that's my choice.
tjeuten
@tjeuten: you're not sending List<T> - you're sending List<SomeClass>. That's a list of a concrete class - and that concrete class must be known and decorated with the appropriate serialization attributes. That's something you can define and represent in XML schema. Other constructs involving generics won't work that easily, and you cannot serialize something that's really "of T" - where T isn't known yet.
marc_s
Allright thx for clarifying that !
tjeuten
WCF does support `Dictionary`.
Christian Hayter
A: 

Hello *, If you return complex types to the wcf service or if you return an entity whose one of the property is of complex type, self tracking entity would have no problems. However if you are using RIA services, the complex types is not supported.

zeeshanhirani