i am Learn MVC create a model then write a linq query then show as belows......
var record = (from TStud in db.tbl_StudentForm
where TStud.stdfrm_id == id
select new
{
TStud.stdfrm_fh_firstname,
TStud.stdfrm_fh_middlename,
TStud.stdfrm_occupation,
TStud.stdfrm_mo_firstname,
TStud.stdfrm_mo_middlename,
TStud.stdfrm_mo_lastname
}).ToList();
and return record to view
and add view name space is are as belows.......
@model IEnumerable<MCAER_MVC.Models.tbl_StudentForm>
but show the error.....plz help me
The model item passed into the dictionary is of type 'System.Collections.Generic.List`1[<>f__AnonymousType4`27[System.Nullable`1[System.Int32],System.String,System.String,System.String,System.String,System.String,System.String,System.String,System.String,System.Nullable`1[System.Int32],System.String,System.String,System.String,System.String,System.String,System.String,System.String,System.String,System.Nullable`1[System.Int32],System.Nullable`1[System.Int32],System.Nullable`1[System.Int32],System.String,System.String,System.String,System.String,System.String,System.String]]', but this dictionary requires a model item of type 'System.Collections.Generic.IEnumerable
thanks in advance
What I have tried:
var record = (from TStud in db.tbl_StudentForm
where TStud.stdfrm_id == id
select new
{
TStud.stdfrm_fh_firstname,
TStud.stdfrm_fh_middlename,
TStud.stdfrm_occupation,
TStud.stdfrm_mo_firstname,
TStud.stdfrm_mo_middlename,
TStud.stdfrm_mo_lastname
}).ToList();
this is my query to tried