Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6784975
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:04:02+00:00 2026-05-26T17:04:02+00:00

I have a association in my poco class, ex: public class Category() { [Key]

  • 0

I have a association in my poco class, ex:

public class Category() {
    [Key]
    public int id { get; set}
    public string Name { get; set; }
    /* HERE */
    public virtual ICollection<Book> Books {get; set;}
}

public class Book() {
    [Key]
    public int id { get; set}
    public string Name { get; set; }
}

I use MVVM patern, MVVM Light and RIA Services Toolkit. My Domain Service implementation contains a method GetCategories that include their books, ex:

public IQueriable<Category> GetCategories()
{
    return Model.Categories.Include("Books").OrderBy(pCategory => pCategory.Name);
}

In my ViewModel I have a DomainCollectionView that load GetGruposQuery. I also have a property for bind a grid and other controls, like:

public ICollectionView CollectionViewCategories {
    get { return myDomainCollectionViewCategories;}
}

I need get a child property CollectionView.Books for bind my controls and ADD, REMOVE itens in view, but this property is only EntityCollection and isn’t a DomainCollectionView that contains methods for ADD, REMOVE, etc.

How I can get the current Books property (of CollectionViewCategories) as DomainCollectionView in my ViewModel?

Thank you!


I solve this question with: (CollectionViewCategories.CurrentItem as Category).Books.Remove(CollectionViewBooks.CurrentItem as Book)

private ICollectionView CreateView(Object source)
{
    CollectionViewSource cvs = new CollectionViewSource();
    cvs.Source = source;
    return cvs.View;            
}
//...
//After CollectionViewCategories loaded:
CollectionViewCategories.CurrentChanged += (s, e) =>
{
    if (CollectionViewCategories.CurrentItem != null)     
    {
        CollectionViewBooks = CreateView(fContext.Categories.Where(p => p.Id == (CollectionViewCategories.CurrentItem as Category).Id).FirstOrDefault().Books);
    }
    else
    {
        CollectionViewBooks = null;
    }
    RaisePropertyChanged("CollectionViewBooks");
};  
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T17:04:03+00:00Added an answer on May 26, 2026 at 5:04 pm

    Why do you need it ? EntityCollection do have these methods (Add,Remove…)
    If you obtain an error while invoking them, it could lead to the fact that the Book class is not fully exposed to the client (lack of insert/update/delete methods on the domainservice)
    Just to clarify, DomainCollectionView is inteded to wrap an EntityCollection primarily for better dealing with MVVM and binding in general (see this link)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following poco class: public class Category : IDisplayName { private ICollection<Category>
Say I have the following POCO classes: public class Parent { public int ID
Say I have the following POCO classes: public class AuditableModel { public int ID
I have a collection of entities with an any-association, like this: public class CreatedLog
I have a Product and Category entity in many-to-many association. I am trying to
Why can you not have a foreign key in a polymorphic association, such as
We have a model association that looks something like this: class Example < ActiveRecord::Base
I have a following association Class Person include Mongoid::Document embeds_many :employments end Class Employment
I have the typical association HABTM Item <-> Tag If i get all the
Why shouldn't in a ER Model an association have attributes with a primary key?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.