Articles in this Series
- Introduction - A DynamicData Attribute Based Permission Solution using User Roles.
- Part 1 - Permissions Attribute (Metadata) Classes.
- Part 2 - Sample Metadata for project.
- Part 3 - The Helper Extension Methods.
- Part 4 - Limit Tables shown on Default page and List, Edit & Details etc.
- Part 5 - Generate Columns/Rows (using IAutoFieldGenerator)
- Part 6 - Miscellaneous bits
- Part 7 - Updating the ListDetails Page
- DynamicData - Limit the Filter Fields
- DynamicData - Automatic Column Update
Sample Metadata
For this project the Northwind database will be used, you can download it from here (it says it is for SQL 2000 but works fine on SQL 2005 and SQL 2008 although if using SQL 2008 the database will be upgraded and then will not run on SQL 2000 or SQL 2005).
Figure 1 has some tables out of the Northwind database that have been added in to the Linq to SQL model.
Figure 1
Listing 1 is the metadata on some Northwind model.
[MetadataType(typeof(OrderMetadata))] [TablePermissions(TablePermissionsAttribute.Permissions.DenyInserts, "Accounts")] public partial class Order { } public class OrderMetadata { [FieldPermissions(FieldPermissionsAttribute.Permissions.DenyEdit, "Sales", "Production")] [FieldPermissions(FieldPermissionsAttribute.Permissions.DenyRead, "Accounts")] public Object OrderDate { get; set; } [FieldPermissions(FieldPermissionsAttribute.Permissions.DenyEdit, "Sales", "Production")] [FieldPermissions(FieldPermissionsAttribute.Permissions.DenyRead, "Accounts")] public Object RequiredDate { get; set; } // entities [HideInFilter] public Object Employee { get; set; } } [TablePermissions(TablePermissionsAttribute.Permissions.DenyRead, "Sales")] public partial class Order_Detail { } [TablePermissions(TablePermissionsAttribute.Permissions.DenyDelete, "Sales")] [MetadataType(typeof(CustomerMetadata))] public partial class Customer { } public class CustomerMetadata { [ScaffoldColumn(false)] public Object UpdatedBy { get; set; } [ScaffoldColumn(false)] public Object UpdatedOn { get; set; } [ScaffoldColumn(false)] public Object CreatedBy { get; set; } [ScaffoldColumn(false)] public Object CreatedOn { get; set; } } [TablePermissions(TablePermissionsAttribute.Permissions.DenyRead, "Sales")] public partial class Employee { } [TablePermissions(TablePermissionsAttribute.Permissions.DenyRead, "Sales")] public partial class Shipper { }
Listing 1
Note: the table level metadata is on the partial class that is implemented from the DBML file this was to workaround a bug in DynamicData 5-12 release but it seems to be the correct place.
Next is the metadata helper classes...
2 comments:
Where to write all this code i am new to Dynamic Data.
Hi kanishka dubey, this is a very old post for DD and .Net 3.5 for .Net see my other post Securing Dynamic Data 4 (Replay) this has a sample you doenload and look at :)
Steve
Post a Comment