views:

79

answers:

1

I work on Northwind database.server MS2008.In linq i active a sp then show me the bellow error:

Syntax :

<dxwgv:ASPxGridView ID="ASPxGridView1" runat="server" 
            AutoGenerateColumns="False" DataSourceID="LinqServerModeDataSource1" 
            KeyFieldName="CategoryID">
            <Columns>
                <dxwgv:GridViewCommandColumn VisibleIndex="0">
                    <EditButton Visible="True">
                    </EditButton>
                    <NewButton Visible="True">
                    </NewButton>
                    <DeleteButton Visible="True">
                    </DeleteButton>
                </dxwgv:GridViewCommandColumn>
                <dxwgv:GridViewDataTextColumn Caption="CategoryID" FieldName="CategoryID" 
                    VisibleIndex="1">
                </dxwgv:GridViewDataTextColumn>
                <dxwgv:GridViewDataTextColumn Caption="CategoryName" FieldName="CategoryName" 
                    VisibleIndex="2">
                </dxwgv:GridViewDataTextColumn>
                <dxwgv:GridViewDataTextColumn Caption="Description" FieldName="Description" 
                    VisibleIndex="3">
                </dxwgv:GridViewDataTextColumn>
            </Columns>
        </dxwgv:ASPxGridView>

 <dxdtlnq:LinqServerModeDataSource ID="LinqServerModeDataSource1" runat="server" 
        onselecting="LinqServerModeDataSource1_Selecting" />

C# syntax:

protected void LinqServerModeDataSource1_Selecting(object sender, DevExpress.Data.Linq.LinqServerModeDataSourceSelectEventArgs e)
        {
             NorthwindDataContext db=new NorthwindDataContext();
             var r = db.SELECT_All_Product();   
            e.QueryableSource = r;
}

Error message:

Error 1 Cannot implicitly convert type 'System.Data.Linq.ISingleResult' to 'System.Linq.IQueryable'. An explicit conversion exists (are you missing a cast?)

What to do solve this error.Why need custing.How to cust .Plz show some syntax

A: 

The reason is the fact that usually procedure returns an IEnumerable<TEntity> result.
You need a table-valued function to work with IQueryable<TEntity>. Take a look at this article for more information.

Devart