Otis wrote:
What's a LinqDataContext ? The linq to sql context? Yes, it's a different thing. Both produce IQueryable<T> objects, but the linq datacontext also can update stuff. I'm not sure if the webversion of devexpress' linqserver control assumes a linq to sql context...
The queryable should just be an IQueryable<T>, without reference to a linq to sql context, so I don't know what kind of errors you run into. If you get cast / other errors, a stack trace is the minimum we need to give pointers... also I think devexpress might have a hint or 2 where to look/how to hook it up...
My bad I missed the space, yes, I meant a Linq DataContext.
Here is a stack trace, from it, it appears this is a DevExpress issue. I have successfully hooked up the LinqServerModeDataSource in the exact same way, however I used a Linq DataContext from a Linq to Sql project. So I am pretty sure this is a valid way to hook it up.
Server Error in '/' Application.
--------------------------------------------------------------------------------
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[NullReferenceException: Object reference not set to an instance of an object.]
DevExpress.Data.Linq.LinqServerModeWebFrontEndOwner.Crash(Exception e) +27
DevExpress.Data.Linq.Helpers.LinqServerModeCache.CrashLanding(Exception e) +65
DevExpress.Data.Linq.Helpers.LinqServerModeCache.CreateTopGroupInfo() +748
DevExpress.Data.Linq.Helpers.LinqServerModeCache.get_TotalGroupInfo() +34
DevExpress.Data.Linq.Helpers.LinqServerModeCache.Count() +25
DevExpress.Data.Linq.Helpers.LinqServerModeWrapper.get_Count() +37
DevExpress.Data.Linq.Helpers.LinqServerModeFrontEnd.get_Count() +35
DevExpress.Data.Helpers.BaseDataControllerHelper.get_Count() +48
DevExpress.Data.DataControllerBase.get_ListSourceRowCount() +52
DevExpress.Data.DataController.get_VisibleListSourceRowCount() +28
DevExpress.Data.DataController.get_VisibleCount() +78
DevExpress.Data.DataController.DoRefresh(Boolean useRowsKeeper) +70
DevExpress.Data.DataControllerBase.DoRefresh() +28
DevExpress.Data.DataController.EndUpdateCore(Boolean sortUpdate) +80
DevExpress.Data.DataControllerBase.EndUpdate() +25
DevExpress.Data.DataControllerBase.OnListSourceChanged() +152
DevExpress.Data.DataControllerBase.SetListSourceCore(IList value) +74
DevExpress.Data.DataControllerBase.SetListSource(IList value) +47
DevExpress.Data.BaseListSourceDataController.SetDataSource(Object dataSource) +62
DevExpress.Web.Data.WebDataControllerProvider.CreateDataController(Object dataSource) +382
DevExpress.Web.Data.WebDataControllerProvider.SetDataSource(Object dataSource) +28
DevExpress.Web.Data.WebDataProxy.SetDataSource(Object dataSource) +98
DevExpress.Web.ASPxGridView.ASPxGridView.PerformDataBinding(String dataHelperName, IEnumerable data) +75
DevExpress.Web.ASPxClasses.Internal.DataHelper.PerformDataBinding(IEnumerable data) +52
DevExpress.Web.ASPxClasses.Internal.DataHelper.OnDataSourceViewSelectCallback(IEnumerable data) +65
System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +29
DevExpress.Web.ASPxClasses.Internal.DataHelper.PerformSelect() +146
DevExpress.Web.ASPxGridView.GridViewDataHelper.PerformSelect() +109
DevExpress.Web.ASPxClasses.Internal.DataContainer.PerformSelect() +117
DevExpress.Web.ASPxClasses.ASPxDataWebControlBase.DataBindCore() +36
DevExpress.Web.ASPxClasses.ASPxDataWebControlBase.DataBind() +143
DevExpress.Web.ASPxClasses.Internal.DataHelperBase.EnsureDataBound(Boolean ensureChildControls) +106
DevExpress.Web.ASPxClasses.Internal.DataHelperBase.EnsureDataBound() +29
DevExpress.Web.ASPxClasses.Internal.DataContainer.EnsureDataBound() +120
DevExpress.Web.ASPxClasses.ASPxDataWebControlBase.OnPreRender(EventArgs e) +39
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
here is my HTML:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="testapp.com.WebForm1" %>
<%@ Register assembly="SD.LLBLGen.Pro.ORMSupportClasses.NET20" namespace="SD.LLBLGen.Pro.ORMSupportClasses" tagprefix="llblgenpro" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
<dxwgv:aspxgridview id="ASPxGridView1" runat="server" autogeneratecolumns="False" datasourceid="LinqServerModeDataSource1" keyfieldname="ProductLinkID">
<columns>
<dxwgv:gridviewdatatextcolumn fieldname="ProductID" visibleindex="0"></dxwgv:gridviewdatatextcolumn>
<dxwgv:gridviewdatatextcolumn fieldname="LinkTitle" visibleindex="1"></dxwgv:gridviewdatatextcolumn>
<dxwgv:gridviewdatatextcolumn fieldname="FileUrl" visibleindex="2"></dxwgv:gridviewdatatextcolumn>
</columns>
</dxwgv:aspxgridview>
<dxdtlnq:linqservermodedatasource id="LinqServerModeDataSource1" runat="server" contexttypename="testapp.Data.Linq.LinqMetaData" onselecting="LinqServerModeDataSource1_Selecting" tablename="ProductLink" />
</form>
</body>
</html>
here is the code behind:
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using testapp.Data.Linq;
using testapp.Data.DatabaseSpecific;
namespace testapp.com
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load( object sender, EventArgs e )
{
}
protected void LinqServerModeDataSource1_Selecting( object sender, DevExpress.Data.Linq.LinqServerModeDataSourceSelectEventArgs e )
{
DataAccessAdapter adapter = new DataAccessAdapter();
e.KeyExpression = "ProductLinkID";
var q = from pl in new LinqMetaData( adapter ).ProductLink
select new { pl.ProductLinkID, pl.ProductID, pl.LinkTitle, pl.FileUrl };
e.QueryableSource = q;
}
}
}