LINQ to SQL on Windows Phone 7.5: Listing 3.

Adding a Reviews property to the Movie Class.

private EntitySet<Review> reviews;

public Movie() {
  reviews = new EntitySet<Review>(attachReview, detachReview);
}

[Association(Storage = "reviews", OtherKey = "MovieId", ThisKey = "MovieId")]
public EntitySet<Review> Reviews {
  get { return this.reviews; }
  set { this.reviews.Assign(value); }
}

private void attachReview(Review review) {
  NotifyPropertyChanging("Reviews");
  review.Movie = this;
}

private void detachReview(Review review) {
  NotifyPropertyChanging("Reviews");
  review.Movie = null;
}

About the Author

Nick Randolph runs Built to Roam, a consulting company that specializes in training, mentoring and assisting other companies build mobile applications. With a heritage in rich client applications for both the desktop and a variety of mobile platforms, Nick currently presents, writes and educates on the Windows Phone platform.

comments powered by Disqus

Featured

Subscribe on YouTube