Exemplo n.º 1
0
        // Methods
        public ALinqTableProvider(ALinqDataModelProvider dataModel, MetaTable table, PropertyInfo contextProperty)
            : base(dataModel)
        {
            this.ContextProperty = contextProperty;
            this.Name            = this.ContextProperty.Name;
            this.EntityType      = table.RowType.Type;
            List <ColumnProvider> list = new List <ColumnProvider>();

            foreach (MetaDataMember member in table.RowType.DataMembers)
            {
                ALinqColumnProvider item = new ALinqColumnProvider(this, member);
                list.Add(item);
                dataModel.EntityMemberLookup[(PropertyInfo)member.Member] = item;
            }
            this._roMembers = new ReadOnlyCollection <ColumnProvider>(list);
        }
Exemplo 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);
        }