Я пытаюсь проверить данные в моем контроллере. Данные, которые я передаю, скопированы из другого поля в том же виде. Условия данных выполняются, данные передаются, но после передачи данных возникает ошибка System.NotSupportedException, которую я тоже не могу отследить.
Просмотр [Я скрываю пару полей и копирую данные из другого поля в эти поля, потому что я не могу проверить данные TaxID с SSN]:
<body>
@Html.DropDownListFor(x => x.TAxIDType, Model.TAxIDType, new { id = "taxid" })
@Html.ValidationMessageFor(x => x.TAxIDType)
@Html.TextBoxFor(x => x.TaxID, new { id="taxidinput", @class = "feintextbox", maxlength = 9, @placeholder = "xxxxxxxxx" })
@Html.ValidationMessageFor(x => x.TaxID)
@Html.TextBoxFor(x => x.FEIN, new { id="feinfield", @class = "feintextbox", maxlength = 10, @placeholder = "xxxxxxxxx" })
@Html.ValidationMessageFor(x => x.FEIN)
@Html.TextBoxFor(x => x.SSN, new { id="ssnfield", @class = "ssntextbox", maxlength = 10, @placeholder = "xxxxxxxxx" })
@Html.ValidationMessageFor(x => x.SSN)
</body>
<script>
$(function () {
$('#feinfield').hide();
});
$(function () {
$('#ssnfield').hide();
});
$("#taxidinput").keypress(function () {
$("#ssnfield").val($(this).val());
});
$("#taxidinput").keypress(function () {
$("#feinfield").val($(this).val());
});
</script>
Контроллер [Я показываю только одно условие (проверка SSN)]:
[HttpPost]
public ActionResult CorporationRegistrationPg1(Testing CorporationRegistration, string EmailID, int SSN, int FEIN, string TAxIDType)
{
if (ModelState.IsValid)
{
using (SUPRTestingDBEntities2 db = new SUPRTestingDBEntities2())
{
if (TAxIDType == "SSN")
{
var obj = db.SUPRTesting.Where(a => a.EmailID.Equals(CorporationRegistration.EmailID) && a.SSN.Equals(CorporationRegistration.SSN)).FirstOrDefault();
//This is where I am getting the error
//System.NotSupportedException
//The specified type member 'FEIN' is not supported in LINQ to Entities.
//Only initializers, entity members, and entity navigation properties are supported.
if (obj != null)
{
if (obj.Active == 0 && obj.Submit == 0)
{
Session["LoginID"] = obj.LoginID.ToString();
Session["EmailAddress"] = obj.EmailID.ToString();
return RedirectToAction("CorporationRegistrationPg2");
} else
{
var Testing = new Testing();
return View(Testing);
}}
else if (obj == null)
{
return View();
}
}
Я объявил все поля в контроллере. Тем не менее, я получаю сообщение об ошибке в моем контроллере.
Модель:
public partial class Testing
{
public int LoginID { get; set; }
[Required]
public string EmailID { get; set; }
public int TaxID { get; set; }
public int SSN { get; set; }
public int FEIN { get; set; }
public int Active { get; set; }
public int Submit { get; set; }
public List<SelectListItem> TAxIDType = new List<SelectListItem>()
{
new SelectListItem() {Text="Select here", Value="default"},
new SelectListItem() {Text="SSN", Value="SSN"},
new SelectListItem() { Text="FEIN", Value="FEIN"}
};
}
Может кто-нибудь помочь мне с этим.