Answers for "how to validate if field is unique based on id using fluentValidation"

0

how to validate if field is unique based on id using fluentValidation

private bool UniqueName(Category category, string name)
{
        ProjecteDataContext _db = new ProjecteDataContext();
        var dbCategory = _db.Categories
                            .Where(x => x.Name.ToLower() == name.ToLower())
                            .SingleOrDefault();

        if (dbCategory == null) 
            return true;

        return dbCategory.ID == category.ID;
}
Posted by: Guest on April-10-2021

Code answers related to "how to validate if field is unique based on id using fluentValidation"

Browse Popular Code Answers by Language