Another ASPxGriView databinding issue

Posts   
 
    
Isz
User
Posts: 108
Joined: 26-Jan-2006
# Posted on: 30-May-2008 17:19:20   

Hi Frans...

The recent build indeed worked, and allowed us to bind to LinqMetaData using the Selecting event of the LinqServerModeDataSource from devex. We are however getting another exception when we attempt to add a summary to the grid.

I posted this issue with devex first, and as expected, they referred me to you, unfortunately without much to go on.

http://devexpress.com/Support/Center/p/Q104692.aspx

Dear DevExpress:

We are evaluating the ASPxGridView as a possible solution fulfill the requirements of a grid heavy UI with our upcoming contract. We are very impressed with the capabilities of your gird. We do, however, work predominately with LLBLGen to support our data layer because it too is a powerful, best-in-class, ORM.

Naturally we would like the two of these technologies to work together in a way that will accommodate efficient use of resources. To us, this appears to be done using LinqServerModeDataSource, so that the ASPxGridview works in server mode.

Included as an attachment is an example solution. The file Default2.aspx is an attempt to get these two to work together, however we are experiencing an exception.

EXCEPTION DETAILS: [InvalidCastException: Specified cast is not valid.] DevExpress.Data.Linq.LinqServerModeWebFrontEndOwner.Crash(Exception e) +6 DevExpress.Data.Linq.Helpers.LinqServerModeCache.CrashLanding(Exception e) +46 DevExpress.Data.Linq.Helpers.LinqServerModeCache.CreateTopGroupInfo() +623 DevExpress.Data.Linq.Helpers.LinqServerModeWrapper.get_Count() +24 DevExpress.Data.Linq.Helpers.LinqServerModeFrontEnd.get_Count() +33 DevExpress.Data.Helpers.BaseDataControllerHelper.get_Count() +26 DevExpress.Data.DataController.get_VisibleListSourceRowCount() +25 DevExpress.Data.DataController.DoRefresh(Boolean useRowsKeeper) +161 DevExpress.Data.DataController.EndUpdateCore(Boolean sortUpdate) +34 DevExpress.Data.DataControllerBase.EndUpdate() +6 DevExpress.Data.DataControllerBase.OnListSourceChanged() +122 DevExpress.Data.DataControllerBase.SetListSourceCore(IList value) +40 DevExpress.Data.DataControllerBase.SetListSource(IList value) +10 DevExpress.Data.BaseListSourceDataController.SetDataSource(Object dataSource) +40 DevExpress.Web.Data.WebDataControllerProvider.CreateDataController(Object dataSource) +339 DevExpress.Web.Data.WebDataControllerProvider.SetDataSource(Object dataSource) +4 DevExpress.Web.Data.WebDataProxy.SetDataSource(Object dataSource) +71 DevExpress.Web.ASPxGridView.ASPxGridView.PerformDataBinding(String dataHelperName, IEnumerable data) +48 DevExpress.Web.ASPxClasses.Internal.DataHelper.PerformDataBinding(IEnumerable data) +26 DevExpress.Web.ASPxClasses.Internal.DataHelper.OnDataSourceViewSelectCallback(IEnumerable data) +90 System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +29 DevExpress.Web.ASPxClasses.Internal.DataHelper.PerformSelect() +190 DevExpress.Web.ASPxGridView.GridViewDataHelper.PerformSelect() +96 DevExpress.Web.ASPxClasses.Internal.DataContainer.PerformSelect() +118 DevExpress.Web.ASPxClasses.ASPxDataWebControlBase.DataBindCore() +15 DevExpress.Web.ASPxClasses.ASPxDataWebControlBase.DataBind() +147 DevExpress.Web.ASPxClasses.Internal.DataHelperBase.EnsureDataBound(Boolean ensureChildControls) +89 DevExpress.Web.ASPxClasses.Internal.DataContainer.EnsureDataBound() +128 DevExpress.Web.ASPxClasses.ASPxDataWebControlBase.OnPreRender(EventArgs e) +19 System.Web.UI.Control.PreRenderRecursiveInternal() +86 System.Web.UI.Control.PreRenderRecursiveInternal() +170 System.Web.UI.Control.PreRenderRecursiveInternal() +170 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2041

Can you please help determine the cause of this problem. If we are able to coordinate the grid view in server mode using llblgen's ORM product, we will likely invest with DevExpress.

Thank you!

Hi,

Thank you for sending the code to us. We have researched the problem and think that this is an LLBLGenPro issue. Please send this project to Frans Bouma for investigation.

If it isn't too much to ask, can you take a look at the project and see if there isn't something else going on? Within the project is Default2.aspx that has a TotalSummary...


        <TotalSummary>
            <dxwgv:ASPxSummaryItem FieldName="Rank" SummaryType="Max" />
        </TotalSummary>

When commented out, the grid works as expected, otherwise it throws an exception as above.

Sorry to keep troubling you on this, hopefully the waves will smooth out. The project can be downloaded from this link...

http://growingtechnologies.com/dl/llblgen/v2.rar

Thanks!

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 30-May-2008 17:25:56   

Please enable tracer LinqExpressionHandler to level 3 like: <add name="LinqExpressionHandler" value="3" />

then run the grid page in debug mode. You'll get the expression tree in text in the debug output window. This will show how the expression tree looks like that is send to the linq provider for execution.

With that, a repro case can be made which could show the problems in a normal query as well (not using the grid)

Without that, it's a needle in a haystack and I don't think devexpress wants to debug our code nor are we looking forward to debugging their code wink so if we know the expression tree layout in text, we can formulate a repro query and see if that results in the same crash. It might be it's the same issue as before, as they call an Execute method which did no post-processing however it now should do that. (so single value results should indeed be single value results, not a list of values)

This error however can also be because the 'Max()' value is returned as a different type than expected.

Frans Bouma | Lead developer LLBLGen Pro
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 30-May-2008 18:14:57   

Please next time create a repro case which works without MVC and other alpha/preview stuff, thanks.

I get a different error, once I've removed all the .net 3.6 stuff from your app:


[ArgumentNullException: Value cannot be null.
Parameter name: expression]
   DevExpress.Data.Linq.LinqServerModeWebFrontEndOwner.Crash(Exception e) +6
   DevExpress.Data.Linq.Helpers.LinqServerModeCache.CrashLanding(Exception e) +46
   DevExpress.Data.Linq.Helpers.LinqServerModeCache.CreateTopGroupInfo() +623
   DevExpress.Data.Linq.Helpers.LinqServerModeWrapper.GetTotalSummary() +22
   DevExpress.Data.Linq.Helpers.LinqServerModeFrontEnd.GetTotalSummary() +12
   DevExpress.Data.ServerModeDataController.CalcTotalSummary() +94
   DevExpress.Data.DataController.DoRefreshCore(Boolean useRowsKeeper) +223
   DevExpress.Data.DataController.DoRefresh(Boolean useRowsKeeper) +315
   DevExpress.Data.DataController.EndUpdateCore(Boolean sortUpdate) +34
   DevExpress.Data.DataControllerBase.EndUpdate() +6
   DevExpress.Web.Data.WebDataControllerProvider.SortGroupChanged(List`1 sortList, Int32 groupCount, String filterExpression, ASPxSummaryItemCollection groupSummary, ASPxSummaryItemCollection totalSummary) +450
   DevExpress.Web.Data.WebDataProxy.SortGroupChanged(List`1 sortList, Int32 groupCount, String filterExpression) +39
   DevExpress.Web.ASPxGridView.ASPxGridView.SynchronizeDataProxy() +200
   DevExpress.Web.ASPxGridView.ASPxGridView.OnDataBound(EventArgs e) +20
   DevExpress.Web.ASPxClasses.Internal.DataHelper.OnDataSourceViewSelectCallback(IEnumerable data) +127
   System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +25
   DevExpress.Web.ASPxClasses.Internal.DataHelper.PerformSelect() +211
   DevExpress.Web.ASPxGridView.GridViewDataHelper.PerformSelect() +117
   DevExpress.Web.ASPxClasses.Internal.DataContainer.PerformSelect() +118
   DevExpress.Web.ASPxClasses.ASPxDataWebControlBase.DataBindCore() +15
   DevExpress.Web.ASPxClasses.ASPxDataWebControlBase.DataBind() +147
   DevExpress.Web.ASPxClasses.Internal.DataHelperBase.EnsureDataBound(Boolean ensureChildControls) +89
   DevExpress.Web.ASPxClasses.Internal.DataContainer.EnsureDataBound() +128
   DevExpress.Web.ASPxClasses.ASPxDataWebControlBase.OnPreRender(EventArgs e) +19
   System.Web.UI.Control.PreRenderRecursiveInternal() +110
   System.Web.UI.Control.PreRenderRecursiveInternal() +193
   System.Web.UI.Control.PreRenderRecursiveInternal() +193
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +6490

I'm currently stepping into the code to see why this goes wrong, but it's a tad hard, as a lot of the code didn't compile.

It also doesn't help that I can't see the inner-exception stacktrace... disappointed The provider crashes with a null-ref exception somewhere but there's no info where...

Frans Bouma | Lead developer LLBLGen Pro
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 30-May-2008 18:27:58   

The issue is caused by the fact that the grid groups on a constant (0) and refers to that constant in the projection by g.Key. This isn't expected (as it's useless, referring to the constant you're grouping on is not something a developer would do), and tehrefore the groupby key reference handler doesn't expect the constant and returns null. I'll try to fix this.

(edit) returning the constant fixed it.

I ran into another problem: in default2.aspx, when I drag user id or user name to the groupby bar, I get unknown column name error popups. Looking into this via the tracer as it seems it's inside the grid.

(edit) the grouping produces a wrong query. I'll look into this what the problem can be. Looks like an old bug which was fixed some time ago about renamed fields which were refered to in an outer query. (this problem is unrelated to the problem you reported).

So devexpress can close this case. Personally I don't think fetching the key again in the groupby projection is useful, as the constant is supplied in the query, so perhaps more linq providers will run into this issue. (but it's for them of course not an issue which is a high priority wink )

The error I get now is a wrong aliased field in the groupby clause. This is a runtime error in our framework (PersistenceCore.FixupDerivedTableTargetingFields makes a mistake somewhere. )

Will fix this as well.

Frans Bouma | Lead developer LLBLGen Pro
Isz
User
Posts: 108
Joined: 26-Jan-2006
# Posted on: 30-May-2008 20:18:39   

Very nice... thanks for digging into this.

If it's not too inconvenient, can you email the solution back to the address in my profile? If I need to reference it again, I'd rather work from it knowing that it will compile for you or devex, as our environments seem a little different.

There is one additional concern that I had with the Default2.aspx. In the code behind, there was code commented out...


            //e.QueryableSource = from u in this._linqMetaData.User
            //                  select new
            //                  {
            //                      UserId = u.UserId,
            //                      UserName = u.UserName,
            //                      Password = u.Password,
            //                      Salt = u.Salt,
            //                      SessionTime = u.SessionTime,
            //                      Rank = u.Rank,
            //                      Active = u.Active,
            //                      CreateDate = u.CreateDate,
            //                      CreateUserId = u.CreateUserId,
            //                      UpdateDate = u.UpdateDate,
            //                      UpdateUserId = u.UpdateUserId
            //                  };

My thought is the above code should be similar, if not the same as performing the following in the aspx code linqDataSource...


    <asp:LinqDataSource ID="LinqDataSource1" runat="server" 
        ContextTypeName="Experimental.LinqToSql.ExperimentalLinqToSqlDataContext" 
        TableName="User"
        Select="new (
            UserId, 
            UserName, 
            Password, 
            Salt, 
            SessionTime, 
            Rank, 
            Active,
            CreateDate,
            CreateUserId,
            UpdateDate,
            UpdateUserId
            )"
        EnableUpdate="True">
    </asp:LinqDataSource>



The latter, binding to an asp.Net LinqDataSource mapped to the dbml generated by your templates works very well.

The former produces the following exception...


[NullReferenceException: Object reference not set to an instance of an object.]
   DevExpress.Data.Linq.LinqServerModeWebFrontEndOwner.Crash(Exception e) +6
   DevExpress.Data.Linq.Helpers.LinqServerModeCache.CrashLanding(Exception e) +46
   DevExpress.Data.Linq.Helpers.LinqServerModeCache.CreateTopGroupInfo() +623
   DevExpress.Data.Linq.Helpers.LinqServerModeWrapper.get_Count() +24
   DevExpress.Data.Linq.Helpers.LinqServerModeFrontEnd.get_Count() +33
   DevExpress.Data.Helpers.BaseDataControllerHelper.get_Count() +26
   DevExpress.Data.DataController.get_VisibleListSourceRowCount() +25
   DevExpress.Data.DataController.DoRefresh(Boolean useRowsKeeper) +161
   DevExpress.Data.DataController.EndUpdateCore(Boolean sortUpdate) +34
   DevExpress.Data.DataControllerBase.EndUpdate() +6
   DevExpress.Data.DataControllerBase.OnListSourceChanged() +122
   DevExpress.Data.DataControllerBase.SetListSourceCore(IList value) +40
   DevExpress.Data.DataControllerBase.SetListSource(IList value) +10
   DevExpress.Data.BaseListSourceDataController.SetDataSource(Object dataSource) +40
   DevExpress.Web.Data.WebDataControllerProvider.CreateDataController(Object dataSource) +339
   DevExpress.Web.Data.WebDataControllerProvider.SetDataSource(Object dataSource) +4
   DevExpress.Web.Data.WebDataProxy.SetDataSource(Object dataSource) +71
   DevExpress.Web.ASPxGridView.ASPxGridView.PerformDataBinding(String dataHelperName, IEnumerable data) +48
   DevExpress.Web.ASPxClasses.Internal.DataHelper.PerformDataBinding(IEnumerable data) +26
   DevExpress.Web.ASPxClasses.Internal.DataHelper.OnDataSourceViewSelectCallback(IEnumerable data) +90
   System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +29
   DevExpress.Web.ASPxClasses.Internal.DataHelper.PerformSelect() +190
   DevExpress.Web.ASPxGridView.GridViewDataHelper.PerformSelect() +96
   DevExpress.Web.ASPxClasses.Internal.DataContainer.PerformSelect() +118
   DevExpress.Web.ASPxClasses.ASPxDataWebControlBase.DataBindCore() +15
   DevExpress.Web.ASPxClasses.ASPxDataWebControlBase.DataBind() +147
   DevExpress.Web.ASPxClasses.Internal.DataHelperBase.EnsureDataBound(Boolean ensureChildControls) +89
   DevExpress.Web.ASPxClasses.Internal.DataContainer.EnsureDataBound() +128
   DevExpress.Web.ASPxClasses.ASPxDataWebControlBase.OnPreRender(EventArgs e) +19
   System.Web.UI.Control.PreRenderRecursiveInternal() +86
   System.Web.UI.Control.PreRenderRecursiveInternal() +170
   System.Web.UI.Control.PreRenderRecursiveInternal() +170
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2041



This may be something you already noticed and are fixing/have fixed. Anyway, the reason this is important is that we will need to add related table fields into the grid, for example:


    <asp:LinqDataSource ID="LinqDataSource" runat="server" 
        ContextTypeName="Experimental.LinqToSql.ExperimentalLinqToSqlDataContext" 
        TableName="User"
        Select="new (UserId, UserName, Password, Rank, MemberUser.MemberId as MemberId, MemberUser.Member.FirstName as FirstName)" 
        EnableUpdate="True">
    </asp:LinqDataSource>

or better yet...


e.QueryableSource = from u in this._linqMetaData.User
                    select new
                    {
                        UserId = u.UserId,
                        UserName = u.UserName,
                        Password = u.Password,
                        Salt = u.Salt,
                        SessionTime = u.SessionTime,
                        Rank = u.Rank,
                        MemberId = u.MemberUser.MemberId,
                        FirstName = u.MemberUser.Member.FirstName
                    }
                    ;

Of course, the code behind method might not even be the right way to achieve our goal (still getting acquainted with the ins/outs of LINQ). Looking at your docs, it seems to add related fields I might need to use Include/Exclude fields like...



// exclude Photo and Notes from employee fetch
var q = (from e in metaData.Employee
         select e).ExcludeFields(e=>e.Photo, e=>e.Notes);


... but that didn't show up in intellisense for me.

Also, it if helps, here is our trace...


: Initial expression to process:
value(SD.LLBLGen.Pro.LinqSupportClasses.DataSource2`1[Experimental.DataEntities.Generic.EntityClasses.UserEntity]).Select(u => new <>f__AnonymousType0`11(UserId = u.UserId, UserName = u.UserName, Password = u.Password, Salt = u.Salt, SessionTime = u.SessionTime, Rank = u.Rank, Active = u.Active, CreateDate = u.CreateDate, CreateUserId = u.CreateUserId, UpdateDate = u.UpdateDate, UpdateUserId = u.UpdateUserId)).OrderBy( => .UserId).Count()


If I had to guess, the order by statement doesn't know about the anonymous type.

Thanks!

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 30-May-2008 20:46:10   

I'll answer your post more in depth later on. What DevExpress should do though is to propagate the inner exception's stacktrace to their output. The exception stacktrace that's now bubbled upwards is the stacktrace from the call to the crash wrapper, but that's not interesting, as the real exception and the real stacktrace is lost (it's not shown in the error page as you've seen).

So they should set the inner exception of the exception they throw to the exception they catch from the code they're calling, so the exception and stacktrace which is the actual error is shown in the webpage and debugging is much easier, also for them, because it now looks as if it appears to be a bug inside their grid which isn't the case. Could you post that remark in your ticket at DevExpress please?

Frans Bouma | Lead developer LLBLGen Pro
Isz
User
Posts: 108
Joined: 26-Jan-2006
# Posted on: 30-May-2008 21:28:19   

Ya... its like shooting in the dark.

I'll post this request right now.

Thanks!

(edit) It 's posted, will let you know what they say.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 01-Jun-2008 12:32:04   

Isz wrote:

Very nice... thanks for digging into this.

If it's not too inconvenient, can you email the solution back to the address in my profile? If I need to reference it again, I'd rather work from it knowing that it will compile for you or devex, as our environments seem a little different.

I removed all pages except Default2.aspx and I cleansed the web.config file from 3.6.0.0 references (basicly removed a lot of elements there), mvc and dyn. data references.

There is one additional concern that I had with the Default2.aspx. In the code behind, there was code commented out...


            //e.QueryableSource = from u in this._linqMetaData.User
            //                  select new
            //                  {
            //                      UserId = u.UserId,
            //                      UserName = u.UserName,
            //                      Password = u.Password,
            //                      Salt = u.Salt,
            //                      SessionTime = u.SessionTime,
            //                      Rank = u.Rank,
            //                      Active = u.Active,
            //                      CreateDate = u.CreateDate,
            //                      CreateUserId = u.CreateUserId,
            //                      UpdateDate = u.UpdateDate,
            //                      UpdateUserId = u.UpdateUserId
            //                  };

My thought is the above code should be similar, if not the same as performing the following in the aspx code linqDataSource...


    <asp:LinqDataSource ID="LinqDataSource1" runat="server" 
        ContextTypeName="Experimental.LinqToSql.ExperimentalLinqToSqlDataContext" 
        TableName="User"
        Select="new (
            UserId, 
            UserName, 
            Password, 
            Salt, 
            SessionTime, 
            Rank, 
            Active,
            CreateDate,
            CreateUserId,
            UpdateDate,
            UpdateUserId
            )"
        EnableUpdate="True">
    </asp:LinqDataSource>



The latter, binding to an asp.Net LinqDataSource mapped to the dbml generated by your templates works very well.

The former produces the following exception...


[NullReferenceException: Object reference not set to an instance of an object.]
   DevExpress.Data.Linq.LinqServerModeWebFrontEndOwner.Crash(Exception e) +6
   DevExpress.Data.Linq.Helpers.LinqServerModeCache.CrashLanding(Exception e) +46
   DevExpress.Data.Linq.Helpers.LinqServerModeCache.CreateTopGroupInfo() +623
   DevExpress.Data.Linq.Helpers.LinqServerModeWrapper.get_Count() +24
   DevExpress.Data.Linq.Helpers.LinqServerModeFrontEnd.get_Count() +33
   DevExpress.Data.Helpers.BaseDataControllerHelper.get_Count() +26
   DevExpress.Data.DataController.get_VisibleListSourceRowCount() +25
   DevExpress.Data.DataController.DoRefresh(Boolean useRowsKeeper) +161
   DevExpress.Data.DataController.EndUpdateCore(Boolean sortUpdate) +34
   DevExpress.Data.DataControllerBase.EndUpdate() +6
   DevExpress.Data.DataControllerBase.OnListSourceChanged() +122
   DevExpress.Data.DataControllerBase.SetListSourceCore(IList value) +40
   DevExpress.Data.DataControllerBase.SetListSource(IList value) +10
   DevExpress.Data.BaseListSourceDataController.SetDataSource(Object dataSource) +40
   DevExpress.Web.Data.WebDataControllerProvider.CreateDataController(Object dataSource) +339
   DevExpress.Web.Data.WebDataControllerProvider.SetDataSource(Object dataSource) +4
   DevExpress.Web.Data.WebDataProxy.SetDataSource(Object dataSource) +71
   DevExpress.Web.ASPxGridView.ASPxGridView.PerformDataBinding(String dataHelperName, IEnumerable data) +48
   DevExpress.Web.ASPxClasses.Internal.DataHelper.PerformDataBinding(IEnumerable data) +26
   DevExpress.Web.ASPxClasses.Internal.DataHelper.OnDataSourceViewSelectCallback(IEnumerable data) +90
   System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +29
   DevExpress.Web.ASPxClasses.Internal.DataHelper.PerformSelect() +190
   DevExpress.Web.ASPxGridView.GridViewDataHelper.PerformSelect() +96
   DevExpress.Web.ASPxClasses.Internal.DataContainer.PerformSelect() +118
   DevExpress.Web.ASPxClasses.ASPxDataWebControlBase.DataBindCore() +15
   DevExpress.Web.ASPxClasses.ASPxDataWebControlBase.DataBind() +147
   DevExpress.Web.ASPxClasses.Internal.DataHelperBase.EnsureDataBound(Boolean ensureChildControls) +89
   DevExpress.Web.ASPxClasses.Internal.DataContainer.EnsureDataBound() +128
   DevExpress.Web.ASPxClasses.ASPxDataWebControlBase.OnPreRender(EventArgs e) +19
   System.Web.UI.Control.PreRenderRecursiveInternal() +86
   System.Web.UI.Control.PreRenderRecursiveInternal() +170
   System.Web.UI.Control.PreRenderRecursiveInternal() +170
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2041

This may be something you already noticed and are fixing/have fixed.

I think it's related to the same issue I ran into: a field is renamed and is present in the groupby. I'll check that code as well before I'll flag this issue as fixed.

Anyway, the reason this is important is that we will need to add related table fields into the grid, for example:


    <asp:LinqDataSource ID="LinqDataSource" runat="server" 
        ContextTypeName="Experimental.LinqToSql.ExperimentalLinqToSqlDataContext" 
        TableName="User"
        Select="new (UserId, UserName, Password, Rank, MemberUser.MemberId as MemberId, MemberUser.Member.FirstName as FirstName)" 
        EnableUpdate="True">
    </asp:LinqDataSource>

or better yet...


e.QueryableSource = from u in this._linqMetaData.User
                    select new
                    {
                        UserId = u.UserId,
                        UserName = u.UserName,
                        Password = u.Password,
                        Salt = u.Salt,
                        SessionTime = u.SessionTime,
                        Rank = u.Rank,
                        MemberId = u.MemberUser.MemberId,
                        FirstName = u.MemberUser.Member.FirstName
                    }
                    ;

Of course, the code behind method might not even be the right way to achieve our goal (still getting acquainted with the ins/outs of LINQ). Looking at your docs, it seems to add related fields I might need to use Include/Exclude fields like...



// exclude Photo and Notes from employee fetch
var q = (from e in metaData.Employee
         select e).ExcludeFields(e=>e.Photo, e=>e.Notes);


... but that didn't show up in intellisense for me.

Related entity fields will cause joins to be added, so you should be careful when adding them. Also, with a generic linq source like the deveexpress' one, you have to take into account that the queryable you pass to it will be wrapped into another query. So any in-memory stuff or any projection oriented code might not work as expected as the projection (select) you're writing in your query isn't the final projection in all cases (as they group on a constant, perhaps you defined a max etc. ), so the query you pass will be wrapped inside another query.

Frans Bouma | Lead developer LLBLGen Pro
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 02-Jun-2008 13:41:50   

Btw, you don't need to use a Linq to sql context anymore, this works too: <dxdtlnq:LinqServerModeDataSource ID="LinqServerModeDataSource1" runat="server"
OnSelecting="LinqServerModeDataSource1_Selecting" />

(working on groupby issue)

(edit) Ok, fixed that, was a small glitch in groupbycollection class.

Looking into your other query which as you said didn't work.... (edit) still fails... looking into where the exception occurs.

which I can reproduce with:


var count = (from c in metaData.Customer 
             select new { CustomerId = c.CustomerId, CompanyName = c.CompanyName }).OrderBy(x=>x.CustomerId).Count();

Odd that it fails though... after so many testruns and wicked queries... oh well...

Frans Bouma | Lead developer LLBLGen Pro
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 02-Jun-2008 15:05:12   

Fixed in next build. The grid seems to work fine now. simple_smile

Frans Bouma | Lead developer LLBLGen Pro