LINQ to SQL issue

7 posts, 0 answers
  1. Michael
    Michael avatar
    44 posts
    Member since:
    Oct 2011

    Posted 23 Feb 2012 Link to this post

    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?

  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 23 Feb 2012 Link to this post

    Hello Michael,

    Check the following demo.
    Grid / LinqToSql Operations

    -Shinu.

  3. Michael
    Michael avatar
    44 posts
    Member since:
    Oct 2011

    Posted 24 Feb 2012 Link to this post

    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.

  4. Michael
    Michael avatar
    44 posts
    Member since:
    Oct 2011

    Posted 27 Feb 2012 Link to this post

    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?

  5. Antonio Stoilkov
    Admin
    Antonio Stoilkov avatar
    522 posts
    Member since:
    Sep 2012

    Posted 29 Feb 2012 Link to this post

    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.

  6. Dustin
    Dustin avatar
    1 posts
    Member since:
    Jan 2012

    Posted 01 Mar 2012 Link to this post

    you got using System.Linq declared? that is how i fixed my error

  7. Antonio Stoilkov
    Admin
    Antonio Stoilkov avatar
    522 posts
    Member since:
    Sep 2012

    Posted 06 Mar 2012 Link to this post

    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.

Back to Top