asp.net using mvc 3 applying kendo ui -


sir can lend me hand in fixing program.. im using kendo ui in asp.net mvc. problem records in database not being display everytime run program display nothing.and indicate error.. saying "{"the entity or complex type 'database.applicant' cannot constructed in linq entities query."}"

here controller:

  private iqueryable<applicant> getapplicant()     {         var applicants = (from in dbcontext.applicants                           select a).take(50).tolist();          return applicants iqueryable<applicant>;     }      public actionresult getapplicant([datasourcerequest] datasourcerequest request)     {         return json(getapplicant().todatasourceresult(request));     }      public actionresult updatecustomer([datasourcerequest] datasourcerequest request, applicant applicant)     {         var customertoupdate = dbcontext.applicants.first(app => app.applicant_id == applicant.applicant_id);          tryupdatemodel(customertoupdate);          dbcontext.savechanges();          return json(modelstate.todatasourceresult());     }      public actionresult insertcustomer([datasourcerequest] datasourcerequest request, applicant customertoadd)     {         if (modelstate.isvalid)         {             dbcontext.applicants.add(customertoadd);             dbcontext.savechanges();         }          return json(new[] { customertoadd }.todatasourceresult(request));     }      public actionresult deletecustomer([datasourcerequest] datasourcerequest request, applicant applicant)     {         var customertodelete = dbcontext.applicants.first(app => app.applicant_id == applicant.applicant_id);          if (customertodelete != null)         {             dbcontext.applicants.remove(customertodelete);             dbcontext.savechanges();         }          return json(new[] { customertodelete }.todatasourceresult(request));     } 

my context:

  public partial class applicant     {         public int applicant_id { get; set; }           public string applicant_lastname { get; set; }         public string applicant_firstname { get; set; }         public string applicant_middlename { get; set; }         public string applicant_address { get; set; }          public string applicant_city { get; set; }         public string applicant_zipcode { get; set; }          public string applicant_phone { get; set; }          public string applicant_email { get; set; }       } 

index:

@{     viewbag.title = "home page"; } <h2>@viewbag.message</h2>  @(html.kendo().grid<kendogridmvccodefirst.viewmodels.applicant>()     .name("applicant")     .toolbar(tb => tb.create())     .pageable()     .datasource(datasource => datasource.ajax()         .model(model => model.id(c => c.applicant_id))         .read("getapplicant", "home")         .update("updatecustomer", "home")         .create("insertcustomer", "home")         .destroy("deletecustomer", "home"))     .columns(cols =>     {         cols.bound(c => c.applicant_lastname).width(200);         cols.bound(c => c.applicant_firstname).width(200);         cols.bound(c => c.applicant_middlename).width(200);         cols.bound(c => c.applicant_address);         cols.bound(c => c.applicant_city);         cols.bound(c => c.applicant_zipcode);         cols.bound(c => c.applicant_phone);         cols.bound(c => c.applicant_email);             cols.command(cmd =>         {             cmd.edit();             cmd.destroy();         });     }) ) 

*what missing in codes? can help

try using return flag jason behave allow get.

json(new [] { customertoadd }.todatasourceresult(request),jsonbehavouir.allowget); 

Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -