Hi, I posted some thread on the WP7 forum before I found this forum. Maybe here I could get more help.
See the original thread:
http://social.msdn.microsoft.com/Forums/en-US/windowsphone7series/thread/62a6b89c-584a-42ac-ba85-ecec0a6f186b
I managed to get the proxy classes generated.
Data retrieval works if I just retrieve the complete collection.
If I ever try to filter data via a LinQ query in the LoadAsync script, I will be doomed. Exception.
For example:
var query from a in data.Entity where a.Name="Hello" select a;
data.LoadAsync(query);
works. Seems like a String constant makes no problem.
String param="Hello" param given as a function parameter to the following line:
var query from a in data.Entity where a.Name=param select a;
data.LoadAsync(query);
crashes.
More complex queries will not work either - I try for example to get a match for a DateTime but no way...
Here is the dump the debugger gives me:
Expression:[10000].Select(o => o)
Expression2:[10000].Where(o => (o.Mahlzeit = value(MyDietLogWP7.ModelHandler+<>c__DisplayClass0).mahlzeit))
A first chance exception of type 'System.MethodAccessException' occurred in mscorlib.dll
A first chance exception of type 'System.MethodAccessException' occurred in System.Data.Services.Client.dll
Error:System.MethodAccessException: MethodAccessException
at System.Reflection.RuntimeConstructorInfo.InternalInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, StackCrawlMark& stackMark)
at System.Activator.InternalCreateInstance(Type type, BindingFlags invokeAttr, Binder binder, Object[] args, CultureInfo culture, StackCrawlMark& stackMark)
at System.Activator.CreateInstance(Type type, Object[] args)
at IQToolkit.ExpressionEvaluator.EvaluatorBuilder.Constant(ConstantExpression c)
at IQToolkit.ExpressionEvaluator.EvaluatorBuilder.Build(Expression exp)
at IQToolkit.ExpressionEvaluator.EvaluatorBuilder.MemberAccess(MemberExpression mLebensmittel Loaded
The first Expression is going through without a problem. The second will lead to the stacktrace above (the first query will not be executed in this example, but works if commented in).
DataServiceQuery<LebensmittelConsumed> lebQuery = (DataServiceQuery<LebensmittelConsumed>)
from o in model.LebensmittelConsumedMenge
select o;
DataServiceQuery<LebensmittelConsumed> lebQuery2 = (DataServiceQuery<LebensmittelConsumed>)
from o in model.LebensmittelConsumedMenge
where o.Mahlzeit==mahlzeit
select o;
Debug.WriteLine("Expression:" + lebQuery.Expression);
Debug.WriteLine("Expression2:" + lebQuery2.Expression);