locked
New Instances RRS feed

  • Question

  • I have a circumstance where I need access to a new instance of a WCF Data Services type, which has not yet been saved to the database, and WILL NOT be saved by WCF Data Services. Basically, WCF data services is used read-only. Normal WCF services are used to update the data.

    The UI of my system is built around WCF Data Services entities. This takes care of instance tracking and stuff, but the data is too complicated for WCF Data Services to update it.

    So, new entity, new window. Window's save button uses WCF to insert records, and then preferably, refresh the existing instance of the entity using WCF Data Services. Primary keys are all Guids, and set by the application.

    So... I guess this renders down to a question. How can I create a tracked WCF Data Services entity, without actually loading it?

    Friday, July 29, 2011 5:50 PM

Answers

  • Hi,

    Let me ask the question the other way :-)

    Why do you need to track an entity if you're not going to modify it using WCF Data Services? The tracking of the DataServiceContext is almost solely useful for updating entities. If you have a read-only usage, then it might not be needed in the first place.

    In any case: You can attach an existing instance to WCF Data Services by calling DataServiceContext.AttachTo. This will start tracking an entity which was not retrieved by a query.

    Thanks,


    Vitek Karas [MSFT]
    Saturday, July 30, 2011 7:37 AM
    Moderator

All replies

  • Hi,

    Let me ask the question the other way :-)

    Why do you need to track an entity if you're not going to modify it using WCF Data Services? The tracking of the DataServiceContext is almost solely useful for updating entities. If you have a read-only usage, then it might not be needed in the first place.

    In any case: You can attach an existing instance to WCF Data Services by calling DataServiceContext.AttachTo. This will start tracking an entity which was not retrieved by a query.

    Thanks,


    Vitek Karas [MSFT]
    Saturday, July 30, 2011 7:37 AM
    Moderator
  • Hi Jerome,

    I am writing to check the status of the issue on your side. Would you mind letting us know the result of the suggestions?

    If you need further assistance, please feel free to let me know. I will be more than happy to be of assistance. 

    Have a nice day.


    Alan Chen[MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Friday, August 5, 2011 8:30 AM
    Moderator