Ask a questionAsk a question
 

AnswerRegisterItemCollection(new ObjectItemCollection()) required?

  • Saturday, November 07, 2009 10:41 PMzeeshan hirani Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    I was wondering if registeritemcollection with new ObjectItemCollection is required or not and what purpose does it serve. I read my ssdl,msl and csdl from the database and create metadataworkspace. 

    var edmcollection = new EdmItemCollection(new XmlReader[] { csdlreader });
    var ssdlcollection = new StoreItemCollection(new XmlReader[] { ssdlreader });
    var mappingcollection = new StorageMappingItemCollection(edmcollection, ssdlcollection,
        new XmlReader[] { mslreader });

    workspace.RegisterItemCollection(edmcollection);
    workspace.RegisterItemCollection(ssdlcollection);
    workspace.RegisterItemCollection(mappingcollection);
    workspace.RegisterItemCollection(new ObjectItemCollection());//not required

    however i have seen some places on the web, where ObjectItemCollection was also registered. but when i remove that line it still works. I am reading the edmx info from the database with my POCO classes.

    Zeeshan

Answers

  • Monday, November 16, 2009 11:12 PMJeff Reed _MSFT_ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    Zeeshan,

    The ObjectItemCollection is only required to be registered if you are using the MetadataWorkspace in a scenario where you will use the object layer i.e. the ObjectContext.  However if you simply want to use the MetadataWorkspace with the EntityConnection (all conceptual layer), there is no need to register an ObjectItemCollection.

    We have been considering the addition of configurable conceptual to object layer mapping.  If added, it won’t show up till post .NET 4.0.    Do you have scenarios in mind that we should consider for configurable conceptual to object layer mapping?

    Thanks,
    -jeff

  • Monday, November 16, 2009 11:16 PMJeff Reed _MSFT_ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Note also that the ObjectContext will register an ObjectItemCollection for you if you construct it from an EntityConnection.

    Thanks,
    -jeff

All Replies

  • Sunday, November 08, 2009 7:55 AMzeeshan hirani Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    I have one more question related to the above question. Is there a one to one mapping between conceptual model and object model? If that is true, is that something that will change in the future?

    Zeeshan
  • Monday, November 16, 2009 11:12 PMJeff Reed _MSFT_ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    Zeeshan,

    The ObjectItemCollection is only required to be registered if you are using the MetadataWorkspace in a scenario where you will use the object layer i.e. the ObjectContext.  However if you simply want to use the MetadataWorkspace with the EntityConnection (all conceptual layer), there is no need to register an ObjectItemCollection.

    We have been considering the addition of configurable conceptual to object layer mapping.  If added, it won’t show up till post .NET 4.0.    Do you have scenarios in mind that we should consider for configurable conceptual to object layer mapping?

    Thanks,
    -jeff

  • Monday, November 16, 2009 11:16 PMJeff Reed _MSFT_ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Note also that the ObjectContext will register an ObjectItemCollection for you if you construct it from an EntityConnection.

    Thanks,
    -jeff