Esempio n. 1
0
 // Methods
 public ALinqColumnProvider(ALinqTableProvider table, MetaDataMember member)
     : base(table)
 {
     this.Member           = member;
     this.Name             = member.Name;
     this.ColumnType       = GetMemberType(member);
     this.IsPrimaryKey     = member.IsPrimaryKey;
     this.IsGenerated      = member.IsDbGenerated;
     this._isAssociation   = member.IsAssociation;
     this.IsCustomProperty = !member.IsAssociation && (this.Member.DbType == null);
     this.Nullable         = this.Member.IsAssociation ? this.Member.Association.IsNullable : this.Member.CanBeNull;
     this.MaxLength        = ProcessMaxLength(this.ColumnType, this.Member.DbType);
     this.IsSortable       = ProcessIsSortable(this.ColumnType, this.Member.DbType);
 }
Esempio n. 2
0
        // Methods
        public ALinqAssociationProvider(ALinqColumnProvider column)
        {
            Func <ALinqTableProvider, bool> predicate = null;

            this.FromColumn = column;
            MetaAssociation        association = column.Member.Association;
            ALinqTableProvider     table       = (ALinqTableProvider)column.Table;
            ALinqDataModelProvider dataModel   = (ALinqDataModelProvider)table.DataModel;

            if (association.OtherMember != null)
            {
                this.ToColumn = dataModel.EntityMemberLookup[(PropertyInfo)association.OtherMember.Member];
            }
            else
            {
                if (predicate == null)
                {
                    predicate = delegate(ALinqTableProvider tp)
                    {
                        return(tp.EntityType == association.OtherType.Type);
                    };
                }
                this.ToTable = ((ALinqDataModelProvider)column.Table.DataModel).DLinqTables.Single <ALinqTableProvider>(predicate);
            }
            if (association.IsMany)
            {
                this.Direction = AssociationDirection.OneToMany;
            }
            else if ((association.OtherMember == null) || association.OtherMember.Association.IsMany)
            {
                this.Direction = AssociationDirection.ManyToOne;
            }
            else
            {
                this.Direction = AssociationDirection.OneToOne;
            }
            List <string> list = new List <string>();

            using (IEnumerator <MetaDataMember> enumerator = column.Member.Association.ThisKey.GetEnumerator())
            {
                //c__DisplayClass3 class3;
                Func <ColumnProvider, bool> func = null;
                //c__DisplayClass3 __locals4 = class3;
                while (enumerator.MoveNext())
                {
                    MetaDataMember thisKeyMetaDataMember = enumerator.Current;
                    if (func == null)
                    {
                        func = delegate(ColumnProvider member)
                        {
                            return(member.Name.Equals(thisKeyMetaDataMember.Name));
                        };
                    }
                    ALinqColumnProvider provider3 = (ALinqColumnProvider)column.Table.Columns.First(func);
                    list.Add(provider3.Name);
                    if (provider3.IsPrimaryKey)
                    {
                        this.IsPrimaryKeyInThisTable = true;
                    }
                    if (association.IsForeignKey)
                    {
                        provider3.IsForeignKeyComponent = true;
                    }
                }
            }
            this.ForeignKeyNames = new ReadOnlyCollection <string>(list);
        }