Ok so my problem is maybe simple but I can't handle it i tried all known for me methods ...
Error looks like this:
My Index:
My BookController:
And for help my class:
Error looks like this:
The model item passed into the dictionary is of type 'System.Data.Objects.ObjectSet`1[Repository.Database.Book]', but this dictionary requires a model item of type 'System.Collections.Generic.IEnumerable`1[Biblioteka.ViewModels.BookViewModel]'.
My Index:
@model IEnumerable<
Biblioteka.ViewModels.BookViewModel
>
@{
ViewBag.Title = "Index";
}
<
h2
>Index</
h2
>
@(Html.Kendo().Grid(Model)
.Name("Grid")
.Columns(columns =>
{
columns.Bound(p => p.BookGenreId).Groupable(false);
columns.Bound(p => p.Title);
columns.Bound(p => p.Author);
})
.Pageable()
.Sortable()
.Scrollable()
.Filterable()
.DataSource(dataSource => dataSource
.Ajax()
.ServerOperation(false)
)
)
My BookController:
namespace
Biblioteka.Controllers
{
public
class
BooksController : Controller
{
//
// GET: /Books/
public
ActionResult Index()
{
return
View(GetData());
}
private
IEnumerable<dynamic> GetData()
{
LibraryEntities ctx;
ctx =
new
LibraryEntities();
return
ctx.Book;
}
private
JsonResult GetView()
{
return
Json(GetData());
}
}
}
And for help my class:
namespace
Biblioteka.ViewModels
{
public
class
BookViewModel
{
public
int
BookId {
get
;
set
; }
public
string
Author {
get
;
set
; }
public
string
Title {
get
;
set
; }
public
Nullable<System.DateTime> ReleaseDate {
get
;
set
; }
public
string
ISBN {
get
;
set
; }
public
int
BookGenreId {
get
;
set
; }
public
int
Count {
get
;
set
; }
public
System.DateTime AddDate {
get
;
set
; }
public
Nullable<System.DateTime> ModifiedDate {
get
;
set
; }
public
BookViewModel()
{
}
public
BookViewModel(Book book)
{
this
.BookId = book.BookId;
this
.Author = book.Author;
this
.Title = book.Title;
this
.ReleaseDate = book.ReleaseDate;
this
.ISBN = book.ISBN;
this
.BookGenreId = book.BookGenreId;
this
.Count = book.Count;
this
.AddDate = book.AddDate;
this
.ModifiedDate = book.ModifiedDate;
}
public
void
Update(Book book)
{
book.BookId =
this
.BookId;
book.Author =
this
.Author;
book.Title =
this
.Title;
book.ReleaseDate =
this
.ReleaseDate;
book.ISBN =
this
.ISBN;
book.BookGenreId =
this
.BookGenreId;
book.Count =
this
.Count;
book.AddDate =
this
.AddDate;
book.ModifiedDate =
this
.ModifiedDate;
}
}
}