Esempio n. 1
0
        public static EntityMapping <TEntity> Map <TEntity>(this DataContextMapping dataContextMapping, TableAttribute tableAttribute) where TEntity : class
        {
            var entityMapping = Map <TEntity>(dataContextMapping);

            entityMapping.TableAttribute = tableAttribute;
            return(entityMapping);
        }
Esempio n. 2
0
        protected override MetaModel CreateModel(Type dataContextType)
        {
            if (dataContextType == null)
            {
                throw ALinq.Error.ArgumentNull("dataContextType");
            }

            DataContextMapping mapping = getMapping(dataContextType);

            //var type = dataContextType;
            //Debug.Assert(type != null);

            //while (mapping == null && type != typeof(DataContext).BaseType && type != null)
            //{
            //    contextMappings.TryGetValue(type, out mapping);
            //    type = type.BaseType;
            //}


            if (mapping == null)
            {
                throw Error.CouldNotFindMappingForDataContextType(dataContextType);
            }

            var attributeProvider = new AttributeProvider(mapping);
            var model             = new AttributedMetaModel(this, dataContextType, attributeProvider);

            return(model);
        }
Esempio n. 3
0
 public AttributeProvider(DataContextMapping mapping)
 {
     if (mapping == null)
     {
         throw Error.ArgumentNull("mapping");
     }
     this.mapping = mapping;
 }
Esempio n. 4
0
        public static DataContextMapping <TContxt> Function <TContxt>(this DataContextMapping <TContxt> contextMapping,
                                                                      Expression <Func <TContxt, object> > predicate,
                                                                      FunctionAttribute function) where TContxt : DataContext
        {
            var mi = GetMember(predicate);

            return(Function(contextMapping, mi, function));
        }
Esempio n. 5
0
 public static DataContextMapping <TContxt> Function <TContxt>(this DataContextMapping <TContxt> contextMapping,
                                                               Expression <Func <TContxt, object> > member, bool isComposable, string name) where TContxt : DataContext
 {
     return(Function(contextMapping, member, new FunctionAttribute()
     {
         IsComposable = isComposable, Name = name
     }));
 }
Esempio n. 6
0
        public static EntityMapping <TEntity> Map <TContext, TEntity>(this DataContextMapping <TContext> dataContextMapping,
                                                                      Expression <Func <TContext, Table <TEntity> > > predicate)
            where TContext : DataContext
            where TEntity : class
        {
            var entityMapping = Map <TEntity>(dataContextMapping);

            return(entityMapping);
        }
Esempio n. 7
0
        public static FunctionAttribute GetFunction <TContxt>(this DataContextMapping <TContxt> entityMapping,
                                                              Expression <Func <TContxt, object> > predicate) where TContxt : DataContext
        {
            var mi = GetMember(predicate);

            if (mi.DeclaringType != typeof(TContxt))
            {
                throw Error.MappedMemberHadNoCorrespondingMemberInType(mi.Name, typeof(TContxt).Name);
            }

            return(entityMapping.GetFunction(mi));
        }
Esempio n. 8
0
        static DataContextMapping <TContxt> Function <TContxt>(this DataContextMapping <TContxt> contextMapping,
                                                               MemberInfo mi,
                                                               FunctionAttribute function) where TContxt : DataContext
        {
            if (mi.DeclaringType != typeof(TContxt))
            {
                throw Error.MappedMemberHadNoCorrespondingMemberInType(mi.Name, typeof(TContxt).Name);
            }

            contextMapping.Add(mi, function);
            return(contextMapping);
        }
Esempio n. 9
0
        public static EntityMapping <TEntity> Map <TEntity>(this DataContextMapping dataContextMapping)
            where TEntity : class
        {
            var entityMapping = dataContextMapping.GetEntityMapping <TEntity>();

            if (entityMapping == null)
            {
                entityMapping = new EntityMapping <TEntity>();
            }

            dataContextMapping.Add(entityMapping);

            return(entityMapping);
        }
Esempio n. 10
0
 public static DataContextMapping <TContxt> Function <TContxt>(this DataContextMapping <TContxt> contextMapping,
                                                               Expression <Func <TContxt, object> > member) where TContxt : DataContext
 {
     return(Function(contextMapping, member, new FunctionAttribute()));
 }