我意識到這里有太多類似的問題。但我無法用任何這些解決方案解決我的問題。 datingDbEntities db = new datingDbEntities(); [Authorize] [HttpGet] public ActionResult FindMatch() { return View(); } [HTTPPost] public ActionResult FindMatch(string searchString) { var users = from m in db.userAcc select m; if (!String.IsNullOrEmpty(searchString)) { users = users.Where(s => s.userAd.Contains(searchString)); } return View(users); }這是我的行動@model IEnumerable<datingo.Models.EntityFramework.userAcc><h2>Index</h2><p> @Html.ActionLink("FindMatch", "Home") @using (Html.BeginForm("FindMatch", "Home", FormMethod.Post)) { <p> Title: @Html.TextBox("SearchString") <br /> <input type="submit" value="Filter" /> </p> }這是我的看法。namespace datingo.Models.EntityFramework{ using System; using System.Collections.Generic; public partial class userAcc { public int userId { get; set; } public string userName { get; set; } public string userPw { get; set; } public string userMail { get; set; } public Nullable<bool> userGender { get; set; } public string userAd { get; set; } public string userSoyad { get; set; } public Nullable<int> userBoy { get; set; } public Nullable<int> userKilo { get; set; } }}如果你需要,這是我的模型。所以,我試圖獲得搜索結果,但是當我點擊提交按鈕時,它給了我“傳入字典的模型項的類型為‘System.Data.Entity.Infrastructure.DbQuery`1[datingo.Models.EntityFramework.userAcc]’,但該字典需要‘datingo.Models.EntityFramework’類型的模型項。用戶帳戶'?!卞e誤。順便說一句,我知道我沒有為表格列表添加所需的視圖,但至少現在對我來說沒有必要。我不知道該怎么做,有很多關于這個列表和搜索操作的教程,它們工作正常但我的不是。
- 2 回答
- 0 關注
- 105 瀏覽
添加回答
舉報
0/150
提交
取消