Skip to content

Instantly share code, notes, and snippets.

@markdstafford
Created July 10, 2012 15:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save markdstafford/3083943 to your computer and use it in GitHub Desktop.
Save markdstafford/3083943 to your computer and use it in GitHub Desktop.
AddLink/DetachLink
using System;
using System.Linq;
using Scratch.RW;
namespace Scratch
{
internal class Program
{
private static DemoService demoService;
private static Category category;
private static Product product;
private static void Main()
{
demoService = new DemoService(new Uri("http://services.odata.org/(S(readwrite))/OData/OData.svc/"));
category = demoService.Categories.Expand("Products").Where(c => c.ID == 1).First();
product = demoService.Products.Where(p => p.ID == 0).First();
SimulateCheckEvent(false);
SimulateCheckEvent(true);
SimulateCheckEvent(false);
SimulateCheckEvent(true);
SimulateCheckEvent(false);
demoService.SaveChanges();
}
public static void SimulateCheckEvent(bool check)
{
if (check)
{
demoService.AddLink(category, "Products", product);
}
else
{
demoService.DetachLink(category, "Products", product);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment