A Silverlight application uses WCF RIA Services for connection to a SQL Server database. Before inserting a bunch of new records into a table, I should check if this table contains any records with a certain value in one of the fields.
I'm somewhat new to Silverlight, so need some advice on right approach in handling WCF RIA Services.
Should I make a request filtering out records on given value, Load it and then, on the client, check if it contains any such records? Something like the following method in Domain service class ProductService
:
public IQueryable<Product> GetProducts(string nameFilter)
{
return this.ObjectContext.Products.Where(p => p.Name.StartsWith(nameFilter));
}
Or should I compose (in the Domain service class) a custom method, which will do all the check on the server-side and only return boolean confirmation?
Which approach is more correct in the context of Silverlight WCF RIA Services?