using System;
using System.Collections.Generic;
using System.Data.Services;
using System.Linq;
using System.ServiceModel.Web;
using System.Web;

namespace SilverlightGridServerPagingSortingAndFiltering.Web
{
    public class WebDataService1 : DataService<NorthwindEntities>
    {
        public static void InitializeService(IDataServiceConfiguration config)
        {
             config.SetEntitySetAccessRule("*", EntitySetRights.AllRead);
             config.SetServiceOperationAccessRule("*", ServiceOperationRights.All);
        }

        [WebGet]
        [SingleResult]
        public int Count(string where)
        {
            return String.IsNullOrEmpty(where) ? CurrentDataSource.Customers.Count() :
                CurrentDataSource.Customers.Where(where).Count();
        }
    }
}
