Created
July 10, 2012 15:12
-
-
Save markdstafford/3083943 to your computer and use it in GitHub Desktop.
AddLink/DetachLink
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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