Print Page | Close Window

Read-Only Entity Model?

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2010
Forum Discription: For .NET 4.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=3079
Printed Date: 17-Oct-2025 at 4:56pm


Topic: Read-Only Entity Model?
Posted By: katit
Subject: Read-Only Entity Model?
Date Posted: 03-Nov-2011 at 8:08am
I need to create another EntityManager for data lookups. It will be based on views from database.
 
I would like to make all of those entities "read only" and as light as possible. I turned off validation and attributes. I also would like to set it so it's read-only so in code only queries can run against this manager. How do I achieve this?
 



Replies:
Posted By: DenisK
Date Posted: 03-Nov-2011 at 11:43am
Hi katit;

By default, database views are read-only. You can make a db view updatable by following this guide.  http://blogs.msdn.com/b/alexj/archive/2009/09/01/tip-34-how-to-work-with-updatable-views.aspx - http://blogs.msdn.com/b/alexj/archive/2009/09/01/tip-34-how-to-work-with-updatable-views.aspx

In DevForce, to limit access to entities, you can

1. Change the member visibility -  http://drc.ideablade.com/xwiki/bin/view/Documentation/model-member-visibility - http://drc.ideablade.com/xwiki/bin/view/Documentation/model-member-visibility

2. Add save authorization attribute -  http://drc.ideablade.com/xwiki/bin/view/Documentation/model-edm-designer-properties#HEntityEDMProperties - http://drc.ideablade.com/xwiki/bin/view/Documentation/model-edm-designer-properties#HEntityEDMProperties

3. Intercept the save on the server by inheriting from EntityServerSaveInterceptor class and override its AuthorizeSave method.  http://drc.ideablade.com/xwiki/bin/view/Documentation/save-lifecycle-server#HInterceptortemplatemethods - http://drc.ideablade.com/xwiki/bin/view/Documentation/save-lifecycle-server#HInterceptortemplatemethods

Hope this helps.



Print Page | Close Window