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

using System.Web.Script.Services;

public class WebDataService : DataService<NorthwindEntities1>
{    
    public static void InitializeService(IDataServiceConfiguration config)
    {            
        config.SetEntitySetAccessRule("*", EntitySetRights.AllRead);
        config.SetServiceOperationAccessRule("*", ServiceOperationRights.All);              
    }

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

