Exemplo n.º 1
0
        protected void SetAbort()
        {
            DataContextAttribute dca = ExtractNestedContextAttribute();

            if (dca == null)
            {
                return;
            }

            ContextManager.Instance.SetAbort(dca.ContextName);
        }
Exemplo n.º 2
0
        private DataContextAttribute ExtractNestedContextAttribute()
        {
            StackTrace stackTrace = new StackTrace();

            StackFrame[] stackFrames = stackTrace.GetFrames();
            foreach (StackFrame stackFrame in stackFrames)
            {
                MethodBase method = stackFrame.GetMethod();
                object[]   attrs  = method.GetCustomAttributes(typeof(DataContextAttribute), false);
                if (attrs.Length > 0)
                {
                    DataContextAttribute dca = attrs[0] as DataContextAttribute;
                    return(dca);
                }
            }
            return(null);
        }
Exemplo n.º 3
0
        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            IEnumerable <Type> typesToRegister = GetType().Assembly.GetTypes()
                                                 .Where(type => !String.IsNullOrEmpty(type.Namespace))
                                                 .Where(
                type =>
                type.BaseType != null && type.BaseType.IsGenericType &&
                type.BaseType.GetGenericTypeDefinition() == typeof(DataEntityTypeConfiguration <>));

            foreach (var type in typesToRegister)
            {
                DataContextAttribute dataContextAttribute = type.GetCustomAttribute <DataContextAttribute>();

                if (dataContextAttribute == null || dataContextAttribute.Type == GetType())
                {
                    dynamic configurationInstance = Activator.CreateInstance(type);
                    modelBuilder.Configurations.Add(configurationInstance);
                }
            }

            modelBuilder.Filter("SoftDeleteFilter", (ISoftDeletable d) => d.IsDeleted, false);
        }