New Posts New Posts RSS Feed: Serialization issues when including a List<string> in a BOS query
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

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

 Post Reply Post Reply
Author
akukucka View Drop Down
Newbie
Newbie
Avatar

Joined: 22-Jul-2010
Location: Rochester, NY
Posts: 11
Post Options Post Options   Quote akukucka Quote  Post ReplyReply Direct Link To This Post Topic: Serialization issues when including a List<string> in a BOS query
    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!
Back to Top
ting View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 27-Mar-2009
Location: San Francisco
Posts: 427
Post Options Post Options   Quote ting Quote  Post ReplyReply Direct Link To This Post 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.
 
 


Edited by ting - 03-Aug-2010 at 5:14pm
Back to Top
akukucka View Drop Down
Newbie
Newbie
Avatar

Joined: 22-Jul-2010
Location: Rochester, NY
Posts: 11
Post Options Post Options   Quote akukucka Quote  Post ReplyReply Direct Link To This Post 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. 
Back to Top
ting View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 27-Mar-2009
Location: San Francisco
Posts: 427
Post Options Post Options   Quote ting Quote  Post ReplyReply Direct Link To This Post 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");
 
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down