0
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)

有没有更简洁的方法来做到这一点?

4

1 回答 1

0

是的,我相信是的……

    var svc = new LocationDataServiceContext();

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

    }

我以为有一个 Exist() 方法……但我想没有。

于 2009-04-06T23:01:37.873 回答