i realised there is too many similar question in here.But I can't solved my problem with any of those solutions.
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);
}
This is my actions
@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>
}
This is my view.
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; }
public string userHair { get; set; }
public string userEye { get; set; }
public string userCountry { get; set; }
public string userFavTeam { get; set; }
public string userBurc { get; set; }
public string userFavMusic { get; set; }
public string userFavFilm { get; set; }
public string userMeslek { get; set; }
public string userEgitim { get; set; }
public byte[] userPhoto { get; set; }
public Nullable<System.DateTime> userBirthday { get; set; }
public int commentParentId { get; set; }
}
}
and this is my model if you need.
So, im trying to get search results but when i click submit button its giving me the
"The model item passed into the dictionary is of type 'System.Data.Entity.Infrastructure.DbQuery`1[datingo.Models.EntityFramework.userAcc]', but this dictionary requires a model item of type 'datingo.Models.EntityFramework.userAcc'."
error.By the way, I know i didnt add needed view for table listing but thats not necessary for me at least now.I don't know what to do, there is many tutorial about this listing and searching actions, they are working properly but mine is not.