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

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

1 Answer 38 Views
LINQ (LINQ specific questions)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Saeid
Top achievements
Rank 1
Saeid asked on 18 Oct 2014, 08:09 PM
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"))

1 Answer, 1 is accepted

Sort by
0
Kaloyan Nikolov
Telerik team
answered on 21 Oct 2014, 11:44 AM
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.
 
Tags
LINQ (LINQ specific questions)
Asked by
Saeid
Top achievements
Rank 1
Answers by
Kaloyan Nikolov
Telerik team
Share this question
or