c# - DbComparisonExpression requires arguments with comparable types -


I am new to using Linq and am trying to create a search that will search with chart number and Display the results will see the new action when the code is running, I get the error "DB Comrpigion Expression requires logic with rational type" I believe that there should be a search type string and some with the chart int int Is but me Not Keane problem how to fix would be greatly appreciate any help!

Controller:

  Public Performance Index (String SearchTerm = Faucet) {Var Model = DB. Patient. Where (r = & gt; search == faucet || r chart number. Ecloss (search)). Choose (R => New Newlist MODEL {chartNumber = R. Chartenumber, FirstName = R.Fst_Name, LastName = r.LastName,}); See Return (Model); }   

Model:

  public class NewListModel {public int chartnumber {get; Set; } Public string first name {receives; Set; } Public String LastName {get; Set; }}   

See:

  @Emelumerable & lt; Project.Models.NewListModel & gt; @ {ViewBag.Title = "Home Page"; } & Lt; Form method = "get" & gt; & Lt; Input type = "search" name = "search term" /> & Lt; Input type = "submit" value = "search by chart number" / & gt; & Lt; / Form & gt; @wunch (Miscellaneous items in the model) {& lt; Div & gt; & Lt; h4 & gt; @ item.ChartNumber & lt; / H4 & gt; & Lt; / Div & gt; & Lt; Div & gt; @ item.FirstName & lt; / Div & gt; & Lt; Div & gt; @ Item.LastName & lt; / Div & gt; }   

New Controller

  Public Action Result Index (string searchTerm = null) {int chartNo; If (searchTerm == faucet || Int32.TryParse (searchTerm, out of chartNo) {var model = db.Patient. Where (R = & gt; Search == empty; r.ChartNumber == chartNo). Select (r = & gt; New Newlostodel {ChartNumber = R. Chartenumber, FirstName = R.Fst_Name, LastName = R. ListName,}); See Return (Model); } else {// enter invalid number}}    

Convert entry to number one int :

  int chartNo = 0; If (searchTerm == faucet || Int32.TryParse (searchTerm, out of chartNo) {var model = db.Patient. Where (r = & gt; searchorm == zero; r chart number == not charts). Choose (.. .); Return ...; } else {// invalid number entered}    

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -