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.
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 :) |
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); } MovableResult.Pack(()=>items);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. |
Likely, there is something wrong with Deserialization process in this case is nearly the following:
If current |