| <%@ ServiceHost Language="C#" Factory="Microsoft.OData.Service.DataServiceHostFactory, Microsoft.OData.Service, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" |
| Service="DataJS.Tests.LargeCollectionService" %> |
| |
| namespace DataJS.Tests |
| { |
| using System; |
| using System.Collections.Generic; |
| using Microsoft.OData.Service; |
| using Microsoft.OData.Service.Common; |
| using System.Linq; |
| using System.ServiceModel; |
| using System.ServiceModel.Web; |
| using System.Web; |
| |
| [ServiceBehavior(IncludeExceptionDetailInFaults = true)] |
| public class LargeCollectionService : DataService<LargeCollection> |
| { |
| // This method is called only once to initialize service-wide policies. |
| public static void InitializeService(DataServiceConfiguration config) |
| { |
| config.SetEntitySetAccessRule("*", EntitySetRights.All); |
| config.SetServiceOperationAccessRule("*", ServiceOperationRights.All); |
| config.UseVerboseErrors = true; |
| } |
| |
| [WebInvoke] |
| public void ResetData() |
| { |
| this.CurrentDataSource.ResetData(); |
| } |
| } |
| |
| public class LargeCollection : ReflectionDataContext, IUpdatable |
| { |
| private static bool dataInitialized; |
| |
| public IQueryable<Customer> Customers |
| { |
| get { return this.GetResourceSetEntities<Customer>("Customers").AsQueryable(); } |
| } |
| |
| public IQueryable<Supplier> Suppliers |
| { |
| get { return this.GetResourceSetEntities<Supplier>("Suppliers").AsQueryable(); } |
| } |
| |
| public void ResetData() |
| { |
| this.ClearData(); |
| |
| IList<Customer> customers = this.GetResourceSetEntities<Customer>("Customers"); |
| foreach (int i in Enumerable.Range(1, 2 * 1024 * 1024)) |
| { |
| customers.Add(new Customer() |
| { |
| ID = i, |
| Name = "Customer " + i |
| }); |
| } |
| |
| IList<Supplier> suppliers = this.GetResourceSetEntities<Supplier>("Suppliers"); |
| foreach (int i in Enumerable.Range(1, 5000)) |
| { |
| suppliers.Add(new Supplier() |
| { |
| ID = i, |
| Name = "Supplier " + i |
| }); |
| } |
| } |
| |
| protected override void EnsureDataIsInitialized() |
| { |
| if (!dataInitialized) |
| { |
| this.ResetData(); |
| dataInitialized = true; |
| } |
| } |
| } |
| |
| public class Customer |
| { |
| public int ID { get; set; } |
| public string Name { get; set; } |
| } |
| |
| public class Supplier |
| { |
| public int ID { get; set; } |
| public string Name { get; set; } |
| } |
| } |