Print Page | Close Window

ModelExplorer - SL4

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2010
Forum Discription: For .NET 4.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=1869
Printed Date: 26-Jan-2026 at 5:59pm


Topic: ModelExplorer - SL4
Posted By: bigfish
Subject: ModelExplorer - SL4
Date Posted: 08-Jun-2010 at 3:36am
The SL3 version of ModelExplorer included a sample Repository.cs
 
SL4 versions of DFSL break this on line 10 in RED after lines 16 and 17 were changed to reflect DFSL4 breaking changes doco.
 
Error is:  The best overloaded method match for 'Infrastructure.Repository.QueryCallback(IdeaBlade.EntityModel.EntityQueriedEventArgs, System.Action<System.Collections.IEnumerable>)' has some invalid arguments.
Can you please give me a pointer as to what I could adjust here in my quest to move ModelExplorer to SL4.
  1. protected void Query(IEntityQuery query, Action<IEnumerable> callback) {
  2. if (null == query) {
  3. QueryCallbackImpl(null, new List<object>() , callback );
  4. return;
  5. }
  6. EntityManager.DefaultQueryStrategy = QueryStrategy.Normal;
  7. try {
  8. EntityManager.ExecuteQueryAsync(
  9. query,
  10. args => QueryCallback(args, callback),
  11. null);
  12. } catch (Exception e) {
  13. QueryExceptionHandler(e, callback);
  14. }
  15. }
  16. private void QueryCallback(EntityQueriedEventArgs args, Action<IEnumerable> callback) {
  17. QueryCallbackImpl(args.Error, args.Results, callback);
  18. }
  19. private void QueryCallbackImpl(Exception e, IEnumerable result, Action<IEnumerable> callback) {
  20. EntityManager.DefaultQueryStrategy = QueryStrategy.CacheOnly;
  21. if (null != e) {
  22. ReportError(e);
  23. }
  24. callback(result);
  25. }



Replies:
Posted By: bigfish
Date Posted: 08-Jun-2010 at 3:37am
Ouch, line numbers went astray on post - sorry!


Posted By: smi-mark
Date Posted: 08-Jun-2010 at 9:02am
The problem is, it is no longer a EntityQueriedEventArgs.

this.EntityManager.ExecuteQueryAsync(query, delegate (EntityQueryOperation args) {
                this.QueryCallback(args, callback);
            }, null);

private void QueryCallback(EntityQueryOperation args, Action<IEnumerable> callback)
        {
           
        }


Posted By: bigfish
Date Posted: 09-Jun-2010 at 5:29am
Thanks, that got me over that hurdle.  There has been quite of lot of changes, like this one below too.
 

public static Type GetUltimateType(Type aType) {

if (null == aType)

return null;

// Get DynamicType conversion if Anonymous Type

return AnonymousFns.IsAnonymousType(aType) ? new DynamicTypeInfo(aType).DynamicType : aType;

}

DynamicTypeInfo no longer takes 1 argument in the constructor, but appears to be a more strongly typed constructor...

public DynamicTypeInfo(string typeName, IEnumerable<string> propertyNames, IEnumerable<Type> propertyTypes);

Any suggestions for a replacement please? I'm finding it hard to do the translation or even delve into the old Ideablade binaries...


Posted By: smi-mark
Date Posted: 09-Jun-2010 at 8:28am
Instead of DynamicTypeInfo(aType) try DynamicTypeInfo.GetTypeInfo(Type type)

I find sometimes it's helpful to use Reflector when you get stuck. You can see that the constructor is now internal, so in Reflector you can right click it and go to Analyze, and see that it's called by DynamicTypeInfo.GetTypeInfo(), which seems to cache to improve performance



Print Page | Close Window