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 7636749
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T07:45:50+00:00 2026-05-31T07:45:50+00:00

I have reading Pro Business Application with Silverlight 4 by Chris Anderson, Regarding the

  • 0

I have reading Pro Business Application with Silverlight 4 by Chris Anderson,
Regarding the topic EXPOSING DATA FROM THE SERVER: USING WCF RIA SERVICES – Presentation Model Types, it is not so details about a presentation model object contains a property exposing a collection of another presentation model object.

I have the basic idea of how to create a presentationModel,
but how about a PresentationModel contains a collection of another PresentationModel?
Example a ProductPM contains a collection of ProductInventoryPM?
How to write the CRUD code at the Domain Service Class?

Thank You!

  • 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-31T07:45:51+00:00Added an answer on May 31, 2026 at 7:45 am

    There’s several things you need to do in your code. First, to be able to see the list of product inventory records, you need to select them as part of your GetProducts domain operation:

    Public Function GetProducts() As IQueryable(Of ProductPM)
        Return From p As Product In Me.ObjectContext.Products.Include("ProductInventories") Select New ProductPM With
                                                                     {.ListPrice = p.ListPrice,
                                                                      .ModifiedDate = p.ModifiedDate,
                                                                      .Name = p.Name,
                                                                      .ProductID = p.ProductID,
                                                                      .ProductNumber = p.ProductNumber,
                                                                      .ProductInventory = From i In p.ProductInventories Select New ProductInventoryPM With
                                                                         {
                                                                            .Quantity = i.Quantity,
                                                                            .ProductID = p.ProductID
                                                                         }
                                                                     }
    End Function
    

    That will get them showing in the second data grid.

    You’ll also need to add a constructor to your ProductPM class that initialises the ProductInventory class:

    Public Sub New()
        ProductInventory = New List(Of ProductInventoryPM)
    End Sub
    

    The final issue is that the insert domain operations are being called in the wrong order. As far as I can tell, the best way to handle this is as follows:

    1. Create an empty Insert domain operation for the ProductInventoryPM object. No logic is required in it, but the method is required in order for the ProductInventoryPM object to be able to be added to the ProductPM’s inventory collection.

      Public Sub InsertProductInventory(ByVal ProductInventoryPM As ProductInventoryPM)
      
      End Sub
      

      NOTE: If you want to be able to add new inventory records after you’ve created the product + initial inventory record, then you will need to add logic to this domain operation after all.

    2. Insert the inventory objects in the ProductPM’s Insert domain operation. An advantage of this is that there’s no need to call SaveChanges.

      Public Sub InsertProduct(ByVal ProductPM As ProductPM)
          Dim Product As New Product
          Product.Name = ProductPM.Name
          Product.ProductNumber = ProductPM.ProductNumber
          Product.ListPrice = ProductPM.ListPrice
          Product.SellStartDate = DateTime.Now
          Product.ModifiedDate = DateTime.Now
          Product.SafetyStockLevel = 1000
          Product.ReorderPoint = 700
          Product.StandardCost = 0
          Product.DaysToManufacture = 3
          Product.rowguid = Guid.NewGuid()
      
          Me.ObjectContext.Products.AddObject(Product)
          Me.ChangeSet.Associate(ProductPM, Product, AddressOf UpdateProductPMKey)
      
          For Each ProductInventoryPM As ProductInventoryPM In ProductPM.ProductInventory
              Dim productInventory As New ProductInventory
      
              With productInventory
                  .Bin = 1
                  .LocationID = 1
                  .ModifiedDate = DateTime.Now
                  .ProductID = ProductInventoryPM.ProductID
                  .Quantity = ProductInventoryPM.Quantity
                  .Shelf = "A"
              End With
      
              Product.ProductInventories.Add(productInventory)
              Me.ChangeSet.Associate(ProductInventoryPM, productInventory, AddressOf UpdateProductInventoryKey)
          Next
      End Sub
      

    Now if you run it, everything should work OK. Let me know how it goes.

    Chris

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

Sidebar

Related Questions

I'm reading the Pro ASP.NET MVC3 Framework book from Freeman and Sanderson and have
I'm pro-grammatically reading emails from Exchange 2010 that have been sent in plain text.
I am reading Pro Spring 2.5 and I have a question to chapter 2
I have been reading through this wonderful website regarding the recommended Python IDEs and
I have finally finished reading Pro ASP.NET MVC 2 Framework Chapter 3: Pre-requisites but
I am reading the Pro Spring 2.5 book and I have a question to
I need to display a PDF in a WPF application. From all the reading
Have been reading about async and tasks and been attempting to convert the CopyFileEx
i have been reading this interesting article which is increasing my every growing confusion
I have been reading up on multiple PHP frameworks, especially the Zend Framework but

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.