I'm really lazy person so i'd like to create the data access service like it was in .NET Remoting where you can use object or generics. So after reading some docs about DO.NET i changed my service to have only 3 methods.

  • Select single (returns SingleQueryResult : MovableResult<project_base_entity_type>)
  • Select multiple (returns MultipleQueryResult : MovableResult<list<project_base_entity_type>>)
  • and accept changes(MovableOperationLog).

Using dynamic linq i'm passing the query string to the service from the client side. Because System.Type is not serializable i'm passing the assembly qualified type name as string and resolving it on service side. After this i'm calling Query.All(my resolved type).Where(my condition). It returns some values. At next step i'm serializing my query result using Pack method of MovableResult. Everything is ok untill i'm trying to Deserialize the data on client side. When i'm trying to do this i'm getting InvalidOperationException {Cannot resolve entity with key 'Country, (1)'.}

If i'm using the Query.All<t> method on service side to get the entities everything is working fine. (I mean there is no exception and i have my countries on client side).

Comparing disconnected states i figured out that when i'm using Query.All(type) it has no items in Versions. All other fields seems to me as equal.

Could you suggest something?..

P.S. The easiest way is to do the generic method using MethodInfo.MakeGenericMethod but it's looks not so good :)

asked Jan 05 '11 at 15:46

Janosh's gravatar image


edited Jan 05 '11 at 15:47

2 Answers:

Thanks Alex for your reply.

I figured out what was wrong.

In WCF sample the data is loading inside Pack method.(Func ()=>Query.All<t>() passed). It is done inside transaction.

If you are selecting some data outside Pack method for example like this:

List<t> items = new List<t>();

foreach(var item in Query.All<t>()) //or Query.All(T)) { items.Add(item); }


you will get this exception on client side because all the selected items will be not in DisconnectedState because they was loaded not in transaction.

answered Jan 06 '11 at 01:09

Janosh's gravatar image


edited Jan 06 '11 at 14:42

Likely, there is something wrong with Domain setup @ the client side. Note that you must anyway create Domain there, even although there will be no objects because of DS. We use memory provider for it in WCF sample.

Deserialization process in this case is nearly the following:

  1. Deserialize DisconnectedState (Domain \ Session isn't necessary for this)
  2. Create Session
  3. Attach DisconnectedState to that Session
  4. Make the Session active (this is necessary on the next step)
  5. Deserialize the original graph of objects with references to persistent objects (e.g. simply an array) - current (active) session is used here to restore the references.

If current Session @ step 5 doesn't have DisconnectedState attached, you might get exactly the described error (~ "no object with specified key") on attempt to deserialize the graph.

answered Jan 05 '11 at 23:07

Alex%20Yakunin's gravatar image

Alex Yakunin

Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!
toggle preview


Once you sign in you will be able to subscribe for any updates here



Asked: Jan 05 '11 at 15:46

Seen: 5,639 times

Last updated: Jan 06 '11 at 14:42

powered by OSQA