This is a migrated thread and some comments may be shown as answers.

LINQ to SQL issue

6 Answers 105 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Michael asked on 23 Feb 2012, 09:09 PM
I am getting the following error when trying to bind a radgrid:

'Telerik.Web.UI.GridDynamicQueryable.GroupBy(System.Linq.IQueryable, string, string, params object[])' is inaccessible due to its protection level

Here is my code in my need date source:

var test = from p in DbContext.Entered_Comments
                   where p.comment_id = 1;
        radgrdResultDetail.DataSource = test;


I have my dbContext declared up above, when i try and declare within the method the same error occurs. Here is my radgrid client side code

<telerik:RadGrid ID="radgrdResultDetail" runat="server" AutoGenerateColumns="False"
                   PageSize="20" GridLines="None" Skin="247" EnableEmbeddedSkins="False" AllowPaging="True"
                   CellSpacing="0" AllowSorting="True" OnPreRender="radgrdResultDetail_PreRender"
                   OnItemDataBound="radgrdResultDetail_ItemDataBound" OnNeedDataSource="radgrdResultDetail_GetData"
                   OnItemCommand="radgrdResultDetail_ItemCommand" meta:resourcekey="radgrdResultDetailResource1">
                   <ClientSettings EnablePostBackOnRowClick="false">
                       <Scrolling AllowScroll="false" UseStaticHeaders="true" />
                       <Animation AllowColumnReorderAnimation="True" AllowColumnRevertAnimation="True" />
                   </ClientSettings>
                   <MasterTableView InsertItemPageIndexAction="ShowItemOnFirstPage" EditMode="InPlace"
                       CommandItemDisplay="bottom" DataKeyNames="comment_id" AllowAutomaticInserts="false" AllowAutomaticUpdates="true"
                       runat="server">
                       <PagerStyle AlwaysVisible="true" />
                       <CommandItemSettings ExportToPdfText="Export to Pdf"></CommandItemSettings>
                       <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column">
                       </RowIndicatorColumn>
                       <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column">
                       </ExpandCollapseColumn>
                       <Columns>
                       </Columns>
                       <EditFormSettings>
                           <EditColumn UniqueName="EditCommandColumn1" FilterControlAltText="Filter EditCommandColumn1 column">
                           </EditColumn>
                       </EditFormSettings>
                   </MasterTableView>
                   <FilterMenu EnableImageSprites="False">
                   </FilterMenu>
                   <HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Hay">
                   </HeaderContextMenu>
               </telerik:RadGrid>

When trying this in a test solution without a telerik grid this works no issues. Are there any specific setting i need to set so this works?

6 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 24 Feb 2012, 05:14 AM
Hello Michael,

Check the following demo.
Grid / LinqToSql Operations

-Shinu.
0
Michael
Top achievements
Rank 1
answered on 24 Feb 2012, 12:28 PM
Thanks for the link but it does not explain to me how my code is returning this error. That splution is using a LinqToSQL datasource which I am not using.
0
Michael
Top achievements
Rank 1
answered on 27 Feb 2012, 11:11 AM
Could someone please assist me with this? Surely the error "'Telerik.Web.UI.GridDynamicQueryable.Where<T>(System.Linq.IQueryable<T>, string, params object[])' is inaccessible due to its protection level" has been encountered before or someone knows the root cause?
0
Antonio Stoilkov
Telerik team
answered on 29 Feb 2012, 11:04 AM
Hi Michael,

You could try the following solutions:
  • Include a select clause in the LINQ query as it is shown in the example below
var test = from p in DbContext.Entered_Comments
                   where p.comment_id == 1
                   select p;
  • If your application is in Medium Thrust you could try setting EnableLinqExpressions to false. Additionally, you could go though the Medium Trust Support help article

All the best,
Antonio Stoilkov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Dustin
Top achievements
Rank 1
answered on 01 Mar 2012, 05:21 PM
you got using System.Linq declared? that is how i fixed my error
0
Antonio Stoilkov
Telerik team
answered on 06 Mar 2012, 08:46 AM
Hello Dustin,

In order for LINQ operations to work a using to System.Linq should be declared. I am glad that the issue you were facing is now resolved. Please do not hesitate to contact us if you have any additional questions.

Greetings,
Antonio Stoilkov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
Michael
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Michael
Top achievements
Rank 1
Antonio Stoilkov
Telerik team
Dustin
Top achievements
Rank 1
Share this question
or