What could possibly be different between the table in a DataContext and an IQueryable<Table> when do
- by Nate Bross
I have a table, where I need to do a case insensitive search on a text field.
If I run this query in LinqPad directly on my database, it works as expected
Table.Where(tbl => tbl.Title.Contains("StringWithAnyCase")
In my application, I've got a repository which exposes IQueryable objects which does some initial filtering and it looks like this
var dc = new MyDataContext();
public IQueryable<Table> GetAllTables()
{
var ret = dc.Tables.Where(t => t.IsActive == true);
return ret;
}
In the controller (its an MVC app) I use code like this in an attempt to mimic the LinqPad query:
var rpo = new RepositoryOfTable();
var tables = rpo.GetAllTables();
// for some reason, this does a CASE SENSITIVE search which is NOT what I want.
tables = tables.Where(tbl => tbl.Title.Contains("StringWithAnyCase");
return View(tables);
The column is defiend as an nvarchar(50) in SQL Server 2008.
Any help or guidance is greatly appreciated!