Error Telerik.OpenAccess.Query.Piece`1[System.String]

2 posts, 0 answers
  1. Saeid
    Saeid avatar
    7 posts
    Member since:
    Jan 2012

    Posted 18 Oct 2014 Link to this post

    Hi I want use this query and pass returned value as string to my view

    var model = db.LobTables.Where(p => p.Id.Equals(2)).Select(p => p.Clob);


    But I got this error
    System.InvalidOperationException: The model item passed into the dictionary is of type 'Telerik.OpenAccess.Query.Piece`1[System.String]', but this dictionary requires a model item of type 'System.String'

    my view is
    @model string
    @(Html.Kendo().EditorFor(m => m).Name("edit"))
  2. Kaloyan Nikolov
    Admin
    Kaloyan Nikolov avatar
    118 posts

    Posted 21 Oct 2014 Link to this post

    Hello Saeid,

    The reason is that you are binding the LINQ query to the UI directly, you should execute it first by calling SingleOrDefault() if you expect a single entity:

    var model = db.LobTables.Where(p => p.Id.Equals(2)).Select(p => p.Clob).SingleOrDefault();


    Regards,
    Kaloyan Nikolov
    Telerik
     
    OpenAccess ORM is now Telerik Data Access. For more information on the new names, please, check out the Telerik Product Map.
     
  3. DevCraft banner
Back to Top