If I use the AnonymousProjectionSelector to build up a dynamic select of an entity with a cache-only query in Silverlight, DevForce goes off into the ether and never returns. If I wrap that in a Coroutine or Task, I'll get this lovely error right away (instead of going off into the ether):
Exception Type: System.Security.VerificationException.
Message: Operation could destabilize the runtime.
at _IB_MjVj_daMH2Mi_pAbAf..ctor()
at lambda_method(Closure , Contract )
at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at IdeaBlade.EntityModel.EntityQuery`1.ExecuteExpression()
at IdeaBlade.EntityModel.EntityQuery`1.ExecuteCacheQuery()
at IdeaBlade.EntityModel.EntityQueryFinder.ExecuteFind(Guid queryGuid)
at IdeaBlade.EntityModel.EntityQueryFinder.Execute()
at IdeaBlade.EntityModel.EntityManager.ExecuteQueryCore(IEntityQuery query, Boolean isAsync)
at IdeaBlade.EntityModel.EntityManager.ExecuteQuery(IEntityQuery query)
|
If I just use a ProjectionSelector instead, everything works fine.
One note that if there isn't any cached data that matches the query, the anonymous projection selector does not cause this error. Only if results are returned does it occur.
The downside unfortunately to using the ProjectionSelector is that it doesn't seem to use the alias name for the column which makes it a real pain when I build a projection anonymously with several columns.
This same technique works fine server-side when doing this SYNC. I can obviously rewrite the Silverlight-side logic to use EntityAspect and just get the values off the entity directly but wondered why the AnonymousProjectionSelector doesn't work.
// build a selection hard-coding what the column is as a test
IProjectionSelector pps = new AnonymousProjectionSelector().Combine("ContractGroupSID", "ContractGroupSID");
// in this example, I know I've loaded the entity with that key into cache
var rootQuery = EntityQueryBuilder.BuildQuery(new EntityKey(typeof(Contract), new object[]{412}));
if (pps != null)
{
// add in the columns to be selected into the projection
var projectionQuery = rootQuery.Select(pps);
// this never returns if it was built with AnonymousProjectionSelector
var projectionResults = manager.ExecuteQuery(projectionQuery.With(QueryStrategy.CacheOnly));
// just for testing purposes. we won't get here if we use anonymous
foreach (object item in projectionResults)
{
if (item != null)
{
Type t = item.GetType();
}
}
}
|
If we simply use this instead it works:
IProjectionSelector pps = new ProjectionSelector("ContractGroupSID", "ContractGroupSID");
|
This is DevForce 2010 6.1.12.