I have an issue that I would appreciate any help with.
Background - I have a database that holds a string (i.e. - StackOverFlow) and I need to compare a passed in value to that string and make it case sensitive.
Right now I have a connection to the database (using EF 4), an IRepo<T> interface (which I use to access the table) and a FindAllMatching method that returns an IQueryable<table> and takes in an Expression<Func<tableName, bool>> expression parameter.
Repo class:
public class TableRepo : IRepo<table>{
private EF4Entity _dc = new EF4Entity();
public IQueryable<table> FindAllMatching(Expression<Func<table, bool>> expression)
{
return _dc.table.Where(expression);
}
}
Calling Code:
public class CallingClass
{
public void CallingMethod(string enteredStringFromTextBoxOnFrontEnd)
{
var tableDB = new TableRepo();
var returnValue = tableDB.FindAllMatching(x => x.ColumnInTableThatHoldsString.CompareTo(enteredStringFromTextBoxOnFrontEnd) ==0);
}
}
Right now, when I pass in a string that matches what is in the table in every way but in case (stackoverflow as opposed to StackOverFlow) the returnValue actually returns a row from the table. If the value that is passed in doesn't match the value contained in the database table exactly, I want it to return null or a count of zero.
I have tried doing .Equals(enteredStringFromTextBoxOnFrontEnd, StringComparison.OrdinalIgnoreCase) and all the other StringComparison values and nothing compares case.
If you need more information please don't hesitate to ask.
Thank you,
Tim