DbContext Save: Access Custom Attribute

I have custom attribute define for each property of Models

public class Student : BaseObject
    public Student()
        // Change this parameter to change the DisplayName 
        // (this name is used in all system messages)
        // property of this object
        : base("Student") { }

    public int StudentId { get; set; }

    public int OfficeAddressId { get; set; }

When you save the student record I want to check for the auditable properties and write them to the audittrack table. I want to do this in

    private void CurrentObjectContext_SavingChanges(object sender, EventArgs e)

can someone direct me to access the property with Auditable(false) and others against each entity.


You can use this LINQ expression to get all properties of the sender annotated with the Auditable attribute (provided IsAuditable is property of the Auditable attribute, where the value from constructor is stored)

var auditableProperties = from p in sender.GetType().GetProperties()
    let attribute = p.GetCustomAttributes(typeof(AuditableAttribute), false).SingleOrDefault() as AuditableAttribute
    where attribute != null && attribute.IsAuditable == true
    select p;

The result of the expression is a collection of PropertyInfo objects.

Need Your Help

Passing Parameter in URL search

javascript search parameter-passing

I am in the process of creating a search functionality. Please see UI example. The following is my HTML

video encryption using aes

c# encryption aes

This code works for smaller files even mp3 and around 50mb video files but it gives me error saying out of memory when it try to encrypt larger video files(>1gb) in c# win application