Print Page | Close Window

Query minimize

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=2671
Printed Date: 02-Jul-2026 at 10:09pm


Topic: Query minimize
Posted By: Darek
Subject: Query minimize
Date Posted: 11-May-2011 at 11:42pm
Is there a way to minimize query generated by DefForce? I have a simple star schema database with a few facts and several dimensional tables, and I am trying to display only a few columns in a grid, from a query returning about 50 at present.



Replies:
Posted By: Darek
Date Posted: 11-May-2011 at 11:50pm
When I've tried to use LIND to limit the number of columns returned, I've received this error:

Unable to locate type: System.Linq.IQueryable`1[[TelerikDDS2.G, TelerikDDS2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], System.Core, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e. Check that the assembly holding this type is available in the bin/exe folder. Also check that both your assemblies and DevForce assemblies have the expected version number on both client and server.

I've used this example:
var myCollectionViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["gridViewSource"];
var qry = mgr.FACT_TRANSACTION
.Select(s1=>new G{A=s1.DIM_POLICY.POLICY_ID,B=s1.DIM_LOCAL_PRODUCT.LOCAL_PRODUCT_NAME})
.Take(100); var op = qry.ExecuteAsync(); op.Completed += (s, args) => { var t1 = args.Results.ToList();   myCollectionViewSource.Source = args.Results;   };

public class G
    {
        public string A { getset; }
        public string B { getset; }
    }  



Posted By: smi-mark
Date Posted: 12-May-2011 at 9:44am
sounds like the type 'G" is not on both the server and the client.

This may help:
http://drc.ideablade.com/xwiki/bin/view/Documentation/knowntypes


Posted By: sbelini
Date Posted: 12-May-2011 at 11:19am
Hi Darek,
 
Smi-mark sugestion will definitely solve your issue regarding the "unable to locate type error".
 
However, if you only intend to display the results in a grid, you won't really need a new type. You could instead use an anonymous projection.
Note that anonymous types cannot be bound to the Silverlight DataGrids. Being that said, DevForce supports binding to anonymous types by using the DynamicTypeConverter (IdeaBlade.Core.DynamicTypeConverter):
 

var myCollectionViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["gridViewSource"];
var qry = mgr.FACT_TRANSACTION
  .Select(s1=>new {A=s1.DIM_POLICY.POLICY_ID,B=s1.DIM_LOCAL_PRODUCT.LOCAL_PRODUCT_NAME})
  .Take(100);
 
var op = qry.ExecuteAsync();
 
op.Completed += (s, args) => {
  var t1 = args.Results.ToList();
  myCollectionViewSource.Source = DynamicTypeConverter.Convert(args.Results);
};
 
 
Silvio.


Posted By: Darek
Date Posted: 12-May-2011 at 12:51pm
DynamicTypeConverter did the trick ... Thanks, Silvio!



Print Page | Close Window