c# - Validate TextBox for Existing data in SQL -
i trying validate inputs database. user should not able save same title twice.
i using code:
private bool exists() { var entity = factory.definitions.calculationparameters.list(); // list() lists values of existing data. if (aspvalidators.validatetextboxes(titletextbox)) //validates textbox string { return entity.where(item => item.title == titletextbox.text); } }
now @ item => ...
part i'm getting error :
cannot implicitly convert type 'system.collections.generic.ienumerable' 'bool'.
i don't know do. please?
so problem of return type of code
private bool exists()
you returning 'system.collections.generic.ienumerable not of bool type.
you can use way
return entity.any(item => item.title == titletextbox.text);
Comments
Post a Comment