Validate TextBox for Existing data in SQL

I am trying to validate some inputs for my database. User should not be able to save the same Title twice.

I am using this code:

private bool Exists()
    var entity = Factory.Definitions.CalculationParameters.List();    

    // List() lists all the values of the already existing data.

    if (AspValidators.ValidateTextBoxes(TitleTextBox)) //Validates the textbox for string
        return entity.Where(item => item.Title == TitleTextBox.Text);

Now at the item => ... part I'm getting this error :

Cannot implicitly convert type 'System.Collections.Generic.IEnumerable' to 'bool'.

I don't know what to do. Help please?


So the problem is of return type of your code

private bool Exists()

You are returning 'System.Collections.Generic.IEnumerable which is not of bool Type.

You can use this way

return entity.Any(item => item.Title == TitleTextBox.Text);

Need Your Help

Unable to run mongod on Mac OS X

osx mongodb homebrew

I've installed mongodb using homebrew. The mongo command runs as expected in terminal but when I run mongod in terminal it returns this: