Print Page | Close Window

Serialization issues when including a List<string> in a BOS query

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=2044
Printed Date: 21-Apr-2026 at 10:29pm


Topic: Serialization issues when including a List<string> in a BOS query
Posted By: akukucka
Subject: Serialization issues when including a List<string> in a BOS query
Date Posted: 03-Aug-2010 at 8:46am
I'm having serialization issues executing a query on the BOS that joins on a List<string>.

The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://ideablade.com/EntityModel:entityQuerySurrogate. The InnerException message was 'Element 'http://ideablade.com/Linq:Value' contains data from a type that maps to the name 'http://schemas.microsoft.com/2003/10/Serialization/Arrays:ArrayOfstring'. The deserializer has no knowledge of any type that maps to this name. Consider using a DataContractResolver or add the type corresponding to 'ArrayOfstring' to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding it to the list of known types passed to DataContractSerializer.'. Please see InnerException for more details.

This is after I've implemented an IKnownTypeProvider on the client that returns a list containing typeof(List<string>).

What am I missing? Thanks!



Replies:
Posted By: ting
Date Posted: 03-Aug-2010 at 4:11pm

Did you also place the IKnownTypeProvider on the server?  The next release of DevForce will handle this, so it should work without you having to do anything.

Can you post the query?  We'd like to see your example.
 
 


Posted By: akukucka
Date Posted: 04-Aug-2010 at 6:55am
Great call - I should have read the error more carefully.  Thanks!  I'm glad the next release of DevForce will handle this automatically.

The query is something along the lines of this:

var titles = EntityManager.Titles.Where(x => x.TitleNumber = 1000).Select(x => x.Title1).ToList();

var orders = from order in EntityManager.Orders
    join title in titles on order.Title equals title
                    where order.Status != "Deleted"
                    select order;

This query is a dumbed-down example, but it includes the join on the List<string>.  I could have joined on the Titles table directly in the main query but the generated SQL was atrocious and timing out for us.  Splitting things up like this has sped things up quite a bit. 


Posted By: ting
Date Posted: 05-Aug-2010 at 3:43pm
You might also consider structuring the second query to something like this (it will still require the IKnownTypeProvider until our next release though):
 
var orders = EntityManager.Orders.Where(o => titles.Contains(o.Title) && o.Status != "Deleted");
 



Print Page | Close Window