New Posts New Posts RSS Feed: Query minimize
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Query minimize

 Post Reply Post Reply
Author
Darek View Drop Down
Newbie
Newbie
Avatar

Joined: 04-Mar-2011
Location: Chicago
Posts: 5
Post Options Post Options   Quote Darek Quote  Post ReplyReply Direct Link To This Post Topic: Query minimize
    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.
Back to Top
Darek View Drop Down
Newbie
Newbie
Avatar

Joined: 04-Mar-2011
Location: Chicago
Posts: 5
Post Options Post Options   Quote Darek Quote  Post ReplyReply Direct Link To This Post 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; }
    }  

Back to Top
smi-mark View Drop Down
DevForce MVP
DevForce MVP
Avatar

Joined: 24-Feb-2009
Location: Dallas, Texas
Posts: 306
Post Options Post Options   Quote smi-mark Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
sbelini View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 13-Aug-2010
Location: Oakland
Posts: 731
Post Options Post Options   Quote sbelini Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
Darek View Drop Down
Newbie
Newbie
Avatar

Joined: 04-Mar-2011
Location: Chicago
Posts: 5
Post Options Post Options   Quote Darek Quote  Post ReplyReply Direct Link To This Post Posted: 12-May-2011 at 12:51pm
DynamicTypeConverter did the trick ... Thanks, Silvio!
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down