none
Validate Self-Tracking Entities RRS feed

  • Question

  • Hi folks

    We are using EF4.0 self-tracking entities as data contract members of a WCF service, so that our ASP.NET site can use the functions of these EF4.0 self-tracking entities to add/change data,so that added/changed data can be sent back to the service (THIS WORKS fine).

    We need to validate this data at the service layer before it hits the underlining Business logic and certainly before it is graphed back onto the Server-side entities or saved to the database.

    If these entities were POCO and used as DTOs then we could use Enterprise Library VAB to attribute the properties of the types.

    Is there a way to do that?

    They will be sending data to the WCF service via these same endpoints and the WCF Service data contracts will need be based on EF4.0 self-tracking entities.

    So I need to be able to validate this non-WCF/non-.NET client data at the WCF Service layer, PRIOR to it being used in my Business Logic Layer!

    It is most desirable to do this at the service layer!!

    These data  types must be EF4.0 self-tracking entities for the ASP.Net to work.

    So, based on Michael Howard's Writing Secure Code: Validate all client data as early as possible, How can I extend these EF4.0 self-tracking entities Data Contract classes So I can Validate the data?

    regards

    GregJF

    Thursday, April 26, 2012 4:35 AM

Answers

  • Hi GregJF,

    Welcome to MSDN Forum.

    Please refer to this link - Self-Tracking Entities with Validation and Tracking State Change Notification.

    This article explains how to extend Self-Tracking Entities (STE) from Entity Framework (EF) 4.0 with validation logic and (tracking) state change notification, with just minimal impact on the T4 files. It builds a two-tier application that submits local changes in a WPF application via a WCF service to a database table. The STE are extended with validation logic that is reusable on client and server. The client is notified when the change tracker of an entity changes its state.

    Best Regards


    Allen Li [MSFT]
    MSDN Community Support | Feedback to us

    Friday, April 27, 2012 3:33 AM
    Moderator