New Posts New Posts RSS Feed: AnonymousProjectionSelector doesn't work on Silverlight
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

AnonymousProjectionSelector doesn't work on Silverlight

 Post Reply Post Reply
Author
pk55 View Drop Down
Senior Member
Senior Member


Joined: 22-Jul-2009
Location: CA
Posts: 105
Post Options Post Options   Quote pk55 Quote  Post ReplyReply Direct Link To This Post Topic: AnonymousProjectionSelector doesn't work on Silverlight
    Posted: 04-Oct-2013 at 5:37pm
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.

Back to Top
kimj View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 1391
Post Options Post Options   Quote kimj Quote  Post ReplyReply Direct Link To This Post Posted: 04-Oct-2013 at 7:02pm
This is a bug, which was first found and fixed in DevForce 2012.  We don't normally port fixes reported in DF2012 back to DF2010 unless they've also been reported in DF2010.  So, now that it has been, we'll get it fixed, most likely in the next release.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down