Linq sorguları yazarken yaşadığmız en büyük sıkıntı debug işlemi yaparken breakpointin sorgu içerisine girmemesi ve bu nedenle düzgün testini yapamayışımız olmuştur.
Ancak sorgudaki kısmı yeni bir method içerine alarak sorgu içerisindeki verilerin kontrolü yapabilmekteyiz.
var customers = from customerList in dataContext.Customers
where customerList.Title.StartsWith("M") == true
select customerList;
Yukarıdaki sorguyu debug ederken kontrol edemiyorken
var customers = from customerList in dataContext.Customers
where IsStartingWith(customerList,"M")
select customerList;
private bool IsStartingWith(CustomerItem customerList, string value)
{
return customerList.Title.StartsWith(value) == true;
}
Yeni bir method ile kontrol edebiliyoruz artık.
Ancak sorgudaki kısmı yeni bir method içerine alarak sorgu içerisindeki verilerin kontrolü yapabilmekteyiz.
var customers = from customerList in dataContext.Customers
where customerList.Title.StartsWith("M") == true
select customerList;
Yukarıdaki sorguyu debug ederken kontrol edemiyorken
var customers = from customerList in dataContext.Customers
where IsStartingWith(customerList,"M")
select customerList;
private bool IsStartingWith(CustomerItem customerList, string value)
{
return customerList.Title.StartsWith(value) == true;
}
Yeni bir method ile kontrol edebiliyoruz artık.