/// <summary>
        /// Returns an AssociationAttribute for the specified association member
        /// </summary>
        /// <param name="member">The metadata member corresponding to the association member</param>
        /// <returns>The Association attribute</returns>
        public System.ComponentModel.DataAnnotations.AssociationAttribute CreateAssociationAttribute(LightSpeedColumnProvider member)
        {
            var metaAssociation = member.Association;

            string associationName = GetAssociationName(metaAssociation);
            string thisKey = FormatMemberList(metaAssociation.ThisKey);
            string otherKey = FormatMemberList(metaAssociation.OtherKey);

            System.ComponentModel.DataAnnotations.AssociationAttribute assocAttrib = new System.ComponentModel.DataAnnotations.AssociationAttribute(associationName, thisKey, otherKey);
            assocAttrib.IsForeignKey = metaAssociation.IsForeignKey;
            return assocAttrib;
        }
        /// <summary>
        /// Returns a collection of all the <see cref="Attribute"/>s we infer from the metadata associated
        /// with the metadata member corresponding to the given property descriptor
        /// </summary>
        /// <param name="propertyDescriptor">A <see cref="PropertyDescriptor"/>.</param>
        /// <returns>a collection of attributes inferred from metadata in the given descriptor</returns>
        private IEnumerable<Attribute> GetEntityMemberAttributes(LightSpeedColumnProvider column, PropertyDescriptor propertyDescriptor)
        {
            List<Attribute> attributes = new List<Attribute>();
            //MetaDataMember member = this._metaType.DataMembers.Where(p => p.Name == propertyDescriptor.Name).SingleOrDefault();
            if (column != null)
            {
                if (column.IsPrimaryKey && propertyDescriptor.Attributes[typeof(KeyAttribute)] == null)
                {
                    attributes.Add(new KeyAttribute());
                }

                if (column.Association != null)
                {
                    if (propertyDescriptor.Attributes[typeof(System.ComponentModel.DataAnnotations.AssociationAttribute)] == null)
                    {
                        var assocAttrib =
                            this.TypeDescriptionContext.CreateAssociationAttribute(column);
                        attributes.Add(assocAttrib);
                    }
                    if(column.Association.IsEagerLoaded && propertyDescriptor.Attributes[typeof(IncludeAttribute)] == null)
                    {
                        attributes.Add(new IncludeAttribute());
                    }
                }

                if (column.IsExcluded && propertyDescriptor.Attributes[typeof(ExcludeAttribute)] == null)
                {
                    attributes.Add(new ExcludeAttribute());
                }
                else
                {
                    attributes.Add(new DataMemberAttribute());
                }

                //if (column.UpdateCheck != UpdateCheck.Never &&
                //    propertyDescriptor.Attributes[typeof(ConcurrencyCheckAttribute)] == null)
                //{
                //    attributes.Add(new ConcurrencyCheckAttribute());
                //}

                //if (column.IsVersion &&
                //    propertyDescriptor.Attributes[typeof(TimestampAttribute)] == null)
                //{
                //    attributes.Add(new TimestampAttribute());
                //}

                bool isStringType = propertyDescriptor.PropertyType == typeof(string) || propertyDescriptor.PropertyType == typeof(char[]);
                if (isStringType && column.ColumnType != null && column.MaxLength > 0 &&
                    propertyDescriptor.Attributes[typeof(StringLengthAttribute)] == null)
                {
                    attributes.Add(new StringLengthAttribute(column.MaxLength));
                }
            }
            return attributes.ToArray();
        }
 public LightSpeedOneToOneIdAssociationProvider(LightSpeedColumnProvider fromColumn, LightSpeedTableProvider toTable, LightSpeedColumnProvider toColumn)
     : base(fromColumn, toTable, toColumn)
 {
     Direction = AssociationDirection.OneToOne;
     ThisKey  = ForeignKeyNames = toColumn.Association.ForeignKeyNames;
     OtherKey = new List<string> { "Id" };
 }
 public LightSpeedOneIdToOneAssociationProvider(LightSpeedColumnProvider fromColumn, LightSpeedTableProvider toTable, LightSpeedColumnProvider toColumn, List<string> foreignKeyNames)
     : base(fromColumn, toTable, toColumn)
 {
     Direction = AssociationDirection.OneToOne;
     ForeignKeyNames = foreignKeyNames.AsReadOnly();
     OtherKey = ForeignKeyNames;
     ThisKey = new List<string> { "Id" };
     IsForeignKey = true;
 }
 protected LightSpeedAssociationProvider(LightSpeedColumnProvider fromColumn, LightSpeedTableProvider toTable, LightSpeedColumnProvider toColumn)
 {
     if(fromColumn == null)
         throw new Exception("fromColumn must not be null in association");
     FromColumn = fromColumn;
     if (toTable == null)
         throw new Exception("toTable must not be null in association");
     ToTable = toTable;
     if (toColumn == null)
         throw new Exception("toColumn must not be null in association");
     ToColumn = toColumn;
     IsEagerLoaded = EagerLoad();
 }