Friday, November 28, 2008

LINQ of the Day

public static bool CustomerHasMultiplier(string ID)
{
return FSP.DC().Pm_VisualCustMultipliers
.Where(m => m.Status == "Active")
.Where(m => m.RecordDeleted == false)
.Any(m => m.VisualCustomerID == ID);
}
All I want to do is knock on the database's door and ask, "Is anybody home?" With SQL, that means setting up a connection, a command, a reader or a data adapter and a dataset, running a query to do a count(*) or at least check to see if any rows were returned. With LINQ, it's a one-statement function that returns a bool.

1 comment:

Angel sky said...

Thanks guys, for sharing this conductive collected data at one place.

queens dwi lawyer