This is a migrated thread and some comments may be shown as answers.

Validate delete in WCF RIA service

1 Answer 20 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Henk
Top achievements
Rank 1
Henk asked on 04 Jan 2011, 04:02 PM
Hi,

In the implementation of the delete method on an OA WCF RIA service I want to check if a value of a property of the object to delete has a specific value to check if the user has the rights to delete the object. If the user doesn't have the rights to delete the object I want to raise an exception. But if I try to read a value of a property of the object to delete in this method I get an exception that I cannot read values from objects which are marked for deletion. How can I achieve this?

Kind Regards.

1 Answer, 1 is accepted

Sort by
0
Jan Blessenohl
Telerik team
answered on 10 Jan 2011, 03:45 PM
Hello Henk,
that is a little tricky. Our Ria provider uses the empty ctor of the context class. To get it working you have to implement this ctor differently.
1. Add a new class derived from the generated context class and implement it like this:
namespace SilverlightApplication2.Web
{
    public partial class NorthwindEntityDiagramsSpecial : NorthwindEntityDiagrams
    {
        public NorthwindEntityDiagramsSpecial(bool readAfterDelete) : base()
        {
            GetScope().TransactionProperties.ReadAfterDelete = readAfterDelete;
        }
        public NorthwindEntityDiagramsSpecial() : this(true)
        {
            // used by OpenAccess Ria provider
        }
    }
}

Now open the Ria tt file and change the line:

string contextTypeName = "NorthwindEntityDiagrams";

to

string contextTypeName = "NorthwindEntityDiagramsSpecial";

after saving the tt file your Ria provider should use the new ctor and the additional setting.

Best wishes,
Jan Blessenohl
the Telerik team
Accelerate your learning with industry's first Telerik OpenAccess ORM SDK. Download today.
Tags
General Discussions
Asked by
Henk
Top achievements
Rank 1
Answers by
Jan Blessenohl
Telerik team
Share this question
or