Skip to main content

Posts

Showing posts with the label Telerik DataAccess

Activity logs through Telerik Data Access

Some time back I had written a blog on managing history for required models ( http://vikutech.blogspot.in/2015/08/implementing-automating-audit-logs-in-telerik-data- access.html ). In this particular example, we would be looking for managing small summary of information based on tables affected in the particular request of context. Like what kind of operation were done on models and by whom. The approach for implementation is to create required model to store summary information and attach DB context events based on required format. The Basic data model for collecting information, just having user identifier and message. /// <summary> /// User activity log domain model /// </summary> public class UserActivityLog : IPrimaryKey<int> { /// <summary> /// Gets or sets the identifier. /// </summary> /// <value>The identifier.</value> public int Id { get; set; } /// <summa...

Implementing/Automating audit logs in Telerik Data Access

Audit logs can be tedious task if done manually, also developer might miss to update audit log implementation on certain level. The codes would be repeated on all places if not centralized. There are many approach available to maintain change history of model/table. Like having single history table and manage all changes of all models in same table. We may maintain in same table with some flags and JSON data for change list. We will look for maintaining history table based on each required data models with minimum effort and performance. To reduce code, I am going to use T4 to generate history models automatically based on original model. Also we are going to take care of Artificial type values. Step 1 - Create a custom attribute to mark model that history need to be maintained. /// <summary> /// Attribute to maintain history table /// </summary> [AttributeUsage(AttributeTargets.Class)] public class ManageHistoryAttribute : Attribute ...

Auto fluent mapping generation for OpenAccess/Telerik DataAccess through T4

There is two way to map code first with DB related entities. The first is data annotation which is like setting attributes and the other one is fluent mapping. Fluent mapping is very powerful and flexible approach to map entities. The only downside of fluent mapping is incompatibility with client side validation where as MVC has inbuilt functionality to validate on client side with data annotation. We will look into basic fluent mapping generation along with data annotation if present. Default data annotation is not compatible with Telerik DataAccess/OpenAccess. This article does not gives information about how fluent mapping works or how to generate it but auto generation of fluent mapping by any give model. Pre-requisites for fluent generation I have took help of two different libraries to generate fluent mapping for OpenAccess. -  MultiOutput.ttinclude  ( https://github.com/subsonic/SubSonic-3.0-Templates/blob/master/ActiveRecord/MultiOutput.ttinclude ) : This is to ...