Again me with another problem. I have problem like this: Non-static method requires a target
So, I created my validation and it works normal when I use it directly in Create View but I need it also not just in create. Long story short this is my validation.
public class EmailUpisaniAttribute : ValidationAttribute
{
private ApplicationDbContext db = new ApplicationDbContext();
public override bool IsValid(object value)
{
if (value is VMUpi VMUpi)
{
var pre = db.Upi.FirstOrDefault(x=>x.Email == VMUpi.Upi.Email && x.Upi_ID != VMUpi.Upi.Upi_ID);
if (pre == null)
{
return true;
}
}
return false;
}
}
So, on that link that I posted they say its probably because of lambda in where but I dont know what can I do to solve this problem.