When I run this query in linqpad:
Customer.Where(c => (c.CustomerName == "test"))
It returns a record that matches.
When I try running the same query in visual studio it does not return any matching records. This is the code I am using:
List<Customer> customerList = new List<Customer>();
using (DBEntities db = new DBEntities())
{
try
{
customerList = db.Customer.Where(c => (c.customerName == "test")).ToList();
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
return customerList;
Can anyone see why this it works in linqpad but does not work in visual studio?
can you try out like this
customerList = db.Customer.
Where(c => String.Compare (c.customerName.ToUpper(),"test".ToUpper()) == 0).ToList();
because there may be problem with the Casesensitive search for customer name.
Try other variation of : String.Compare Method as per you need
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With