views:

68

answers:

1
var svc = new LocationDataServiceContext();
var q = from c in svc.LocationTable
                      where c.ID == int.Parse(location.ID)
                      select c;
if (q.ToArray().Length == 0)

id there a neater way to do this?

A: 

yes, I believe so...

    var svc = new LocationDataServiceContext();

    if (svc.LocationTable.SingleOrDefault(c => c.ID == int.Parse(location.ID) != null))
    {

    }

I thought there was an Exist() method... but I guess not.

J.13.L
The Exist() method is part of IList<T> or one of its bases... But you would want to convert it to a List cause then you'd be pulling all the records...
J.13.L

related questions