public static TableAttribute GetTableAttribute(Type type) { return(_tableAttributeCache.GetOrAdd(type, (t) => { return ModelReflection.TableAttribute(t); })); }
public ColumnMember(PropertyInfo pi) : base(pi) { this.ColumnAttribute = ModelReflection.ColumnAttribute(pi); if (ColumnAttribute != null) { this.IsPrimaryKey = ColumnAttribute.IsPrimaryKey; this.IsAutoIdentity = ColumnAttribute.IsAutoIdentity; this.IsForReadOnly = ColumnAttribute.IsForReadOnly; this.Name = ColumnAttribute.Name ?? pi.Name; this.Skip = ColumnAttribute.IsForReadOnly; } }
public static String ColumnName(PropertyInfo pi) { var ca = ModelReflection.ColumnAttribute(pi); if (ca == null) //it's not a column! { return(null); } if (!String.IsNullOrEmpty(ca.Name)) { return(ca.Name); } else { return(pi.Name); } }
public ReferencedObjectMember(PropertyInfo pi) : base(pi) { this.ReferencedObjectAttribute = ModelReflection.ReferencedObjectAttribute(pi); this.ReferencedColumnMember = Model.ColumnMemberForPropertyName(DeclaringType, ReferencedObjectAttribute.PropertyName).Clone() as ColumnMember; this.ReferencedColumnIsNullable = ReflectionHelper.IsNullableType(ReferencedColumnProperty.PropertyType) || ReferencedColumnAttribute.CanBeNull; if (this.IsLazy) { this.TableName = Model.TableName(this.UnderlyingGenericType); this.DatabaseName = Model.DatabaseName(this.UnderlyingGenericType); this.SchemaName = Model.SchemaName(this.UnderlyingGenericType); this.UseNoLock = Model.UseNoLock(this.UnderlyingGenericType); } else { this.TableName = Model.TableName(this.Type); this.DatabaseName = Model.DatabaseName(this.Type); this.SchemaName = Model.SchemaName(this.Type); this.UseNoLock = Model.UseNoLock(this.Type); } }
public ChildCollectionMember(PropertyInfo pi) : base(pi) { var attribute = ModelReflection.ChildCollectionAttribute(pi); this.AlwaysInclude = attribute.AlwaysInclude; if (this.IsLazy) { this.CollectionType = ReflectionHelper.GetUnderlyingTypeForCollection(this.UnderlyingGenericType); } else { this.CollectionType = ReflectionHelper.GetUnderlyingTypeForCollection(this.Type); } if (!String.IsNullOrWhiteSpace(attribute.ParentColumnName)) { this.ParentReferencedMember = Model.ColumnMemberForPropertyName(pi.DeclaringType, attribute.ParentColumnName).Clone() as ColumnMember; } else { this.ParentReferencedMember = Model.ColumnsPrimaryKey(pi.DeclaringType).FirstOrDefault().Clone() as ColumnMember; } if (!String.IsNullOrWhiteSpace(attribute.ChildColumnName)) { this.ReferencedColumn = Model.ColumnMemberForPropertyName(this.CollectionType, attribute.ChildColumnName).Clone() as ColumnMember; } else { this.ReferencedColumn = Model.ColumnMemberForPropertyName(this.CollectionType, this.ParentReferencedColumnName).Clone() as ColumnMember; } this.TableName = Model.TableName(this.CollectionType); this.DatabaseName = Model.DatabaseName(this.CollectionType); this.SchemaName = Model.SchemaName(this.CollectionType); this.UseNoLock = Model.UseNoLock(this.CollectionType); }