1
votes

I'm trying to present MySQL server data in a silverlight client and my current plan of attack is to use Entity Framework to MySQL with RIA Services providing the data access between the Silverlight Client and Entity Framework.

However, I'm only trying to present data to the user and I do not want the possibility of me or someone else being able to change the data in MySQL.

In short, I wish there was a way to simply ignore the setters for all entity types. I only want getters. I want "read-only" access to MySQL. However, it seems my only option is to change "Setter" on each individual field to either Internal, Private, Protected, or Public.

Is there a better way to accomplish what I'm trying to do?

2

2 Answers

6
votes

If you're using RIA Services...

When you create a Domain Service Class (which is in essence what RIA is), it will bring up a dialog that you can click "enable editing" on. In your case, just don't click it and none of the editing functionality will be generated.

RIA Services is for connecting the server and the client, and it can just Not generate the CUD part of teh CRUD

from some blog
(source: silverlightshow.net)

3
votes

With the caveat that I've never used RIA services, from what I understand it's built on top of ADO.NET Data Services. There's no way (as far as I know) to stop the creation of property setters in the Silverlight generated proxy, but you can lock down the data service itself with a bit of code in its static InitializeService() method:

public class MyDataService : DataService<MyEntityModel>
{
    public static void InitializeService(IDataServiceConfiguration config)
    {
        // make all entity sets read-only:
        config.SetEntitySetAccessRule("*", EntitySetRights.AllRead);

        // make the (example) CommentEntitySet read/writeable:
        config.SetEntitySetAccessRule("CommentEntitySet", EntitySetRights.All);
    }
}

With this method, the data service will disallow changes to any entity set except CommentEntitySet (which I included to illustrate the way in which you can can override the access rule to individual entity sets after the first line, which sets the default access rule for all entity sets to AllRead).