public DataServiceAssociationProvider(AssociationDirection direction,
     ColumnProvider fromColumn, TableProvider toTable, IList<String> foreignKeyNames) {
     Direction = direction;
     FromColumn = fromColumn;
     ToTable = toTable;
     ForeignKeyNames = new ReadOnlyCollection<string>(foreignKeyNames);
 }
示例#2
0
 protected override MetaTable CreateTable(TableProvider provider)
 {
     if (_getVisibleColumns == null)
             return new SecureMetaTable(this, provider);
        else
             return new SecureMetaTable(this, provider, _getVisibleColumns);
 }
        /// <summary>
        /// ctor
        /// </summary>
        /// <param name="table">the table this column belongs to</param>
        protected ColumnProvider(TableProvider table) {
            if (table == null) {
                throw new ArgumentNullException("table");
            }

            Table = table;
        }
        public SimpleColumnProvider(TableProvider table, PropertyDescriptor prop)
            : base(table) {
            _prop = prop;
            Name = _prop.Name;
            ColumnType = _prop.PropertyType;
            // TODO: do we really need to set EntityTypeProperty
            //EntityTypeProperty = prop;
            Nullable = true;

            IsSortable = true;
        }
示例#5
0
		public DLinqColumnProvider (TableProvider owner, MetaDataMember meta)
			: base (owner)
		{
			if (owner == null)
				throw new ArgumentNullException ("owner");
			if (meta == null)
				throw new ArgumentNullException ("meta");

			// FIXME: fill more
			Name = meta.Name;
			Nullable = meta.CanBeNull;
		}
 public SimpleColumnProvider(TableProvider tableProvider, PropertyDescriptor propertyDescriptor)
     : base(tableProvider) {
     if (propertyDescriptor.PropertyType == null) {
         throw new ArgumentNullException(DynamicDataResources.SimpleColumnProvider_ColumnTypeRequired);
     }
     Name = propertyDescriptor.Name;
     ColumnType = propertyDescriptor.PropertyType;
     IsPrimaryKey = propertyDescriptor.Attributes.OfType<KeyAttribute>().Any();
     Nullable = Misc.TypeAllowsNull(ColumnType);
     IsReadOnly = propertyDescriptor.IsReadOnly;
     IsSortable = true;
 }
 public DataServiceColumnProvider(TableProvider table, PropertyInfo prop, bool isKey)
     : base(table) {
     _prop = prop;
     EntityTypeProperty = prop;
     Name = _prop.Name;
     ColumnType = _prop.PropertyType;
     IsPrimaryKey = isKey;
     IsSortable = true;
     IsGenerated = false; // We don't have a way of knowing this...could be an issue
     IsForeignKeyComponent = false; // No FKs in Astoria
     IsCustomProperty = false; // All properties are considered part of the contract in Astoria client
     Nullable = DataServiceUtilities.IsNullableType(ColumnType);
 }
示例#8
0
 public SimpleColumnProvider(TableProvider tableProvider, PropertyDescriptor propertyDescriptor)
     : base(tableProvider)
 {
     if (propertyDescriptor.PropertyType == null)
     {
         throw new ArgumentNullException(DynamicDataResources.SimpleColumnProvider_ColumnTypeRequired);
     }
     Name         = propertyDescriptor.Name;
     ColumnType   = propertyDescriptor.PropertyType;
     IsPrimaryKey = propertyDescriptor.Attributes.OfType <KeyAttribute>().Any();
     Nullable     = Misc.TypeAllowsNull(ColumnType);
     IsReadOnly   = propertyDescriptor.IsReadOnly;
     IsSortable   = true;
 }
示例#9
0
        public DLinqColumnProvider(TableProvider owner, MetaDataMember meta)
            : base(owner)
        {
            if (owner == null)
            {
                throw new ArgumentNullException("owner");
            }
            if (meta == null)
            {
                throw new ArgumentNullException("meta");
            }

            // FIXME: fill more
            Name     = meta.Name;
            Nullable = meta.CanBeNull;
        }
 private static DLinqColumnProvider FindColumn(TableProvider table, String columnName) {
     // 
     return (DLinqColumnProvider)table.Columns.First(member => member.Name.Equals(columnName));
 }
 protected override MetaTable CreateTable(TableProvider provider) {
     return new CustomMetaTable(this, provider);
 }
示例#12
0
 public MetaTable(MetaModel metaModel, TableProvider tableProvider) {
     _tableProvider = tableProvider;
     Model = metaModel;
 }
 private DataServiceColumnProvider(TableProvider table)
     : base(table) {
 }
示例#14
0
文件: MetaTable.cs 项目: nobled/mono
		internal MetaTable (MetaModel model, TableProvider provider, ContextConfiguration configuration)
		{
			bool scaffoldAllTables;
			
			this.model = model;
			Provider = provider;
			if (configuration != null) {
				ScaffoldAllTables = scaffoldAllTables = configuration.ScaffoldAllTables;
				Func <Type, TypeDescriptionProvider> factory = configuration.MetadataProviderFactory;
				if (factory != null) {
					Type t = EntityType;
					TypeDescriptionProvider p = factory (t);
					if (p != null)
						TypeDescriptor.AddProvider (p, t);
				}
			} else
				scaffoldAllTables = false;
			
			ScaffoldTableAttribute attr = null;
			MetaModel.GetDataFieldAttribute <ScaffoldTableAttribute> (Attributes, ref attr);
			Scaffold = attr != null ? attr.Scaffold : scaffoldAllTables;
			DataContextType = provider.DataModel.ContextType;
			
			var columns = new List <MetaColumn> ();
			var primaryKeyColumns = new List <MetaColumn> ();
			var foreignKeyColumnNames = new List <string> ();
			MetaColumn mc;
			
			foreach (var c in provider.Columns) {
				// this seems to be the determining factor on whether we create
				// MetaColumn or MetaForeignKeyColumn/MetaChildrenColumn. As the
				// determination depends upon the relationship direction, we must
				// check that using the ColumnProvider's association, if any.
				//
				//  http://msdn.microsoft.com/en-us/library/system.web.dynamicdata.metaforeignkeycolumn.aspx
				//  http://msdn.microsoft.com/en-us/library/system.web.dynamicdata.metachildrencolumn.aspx
				//  http://forums.asp.net/t/1426992.aspx
				var association = c.Association;
				if (association == null)
					mc = new MetaColumn (this, c);
				else {
					var dir = association.Direction;
					if (dir == AssociationDirection.OneToOne || dir == AssociationDirection.ManyToOne)
						mc = new MetaForeignKeyColumn (this, c);
					else
						mc = new MetaChildrenColumn (this, c);
				}
				
				columns.Add (mc);
				if (c.IsPrimaryKey)
					primaryKeyColumns.Add (mc);

				if (mc is MetaForeignKeyColumn)
					foreignKeyColumnNames.Add (c.Name);
			}
			
			Columns = new ReadOnlyCollection <MetaColumn> (columns);
			PrimaryKeyColumns = new ReadOnlyCollection <MetaColumn> (primaryKeyColumns);
			if (foreignKeyColumnNames.Count == 0)
				ForeignKeyColumnsNames = String.Empty;
			else
				ForeignKeyColumnsNames = String.Join (",", foreignKeyColumnNames.ToArray ());
			
			HasPrimaryKey = primaryKeyColumns.Count > 0;

			// See http://forums.asp.net/t/1388561.aspx
			//
			// Also, http://forums.asp.net/t/1307243.aspx - that seems to be out of
			// scope for us, though (at least for now)
			IsReadOnly = primaryKeyColumns.Count == 0;
			
			// FIXME: fill more properties.
		}
示例#15
0
 public SecureMetaTable(MetaModel metaModel, TableProvider tableProvider)
     : base(metaModel, tableProvider)
 {
 }
 private static DLinqColumnProvider FindColumn(TableProvider table, String columnName)
 {
     //
     return((DLinqColumnProvider)table.Columns.First(member => member.Name.Equals(columnName)));
 }
 public CustomMetaTable(MetaModel metaModel, TableProvider tableProvider) :
     base(metaModel, tableProvider) {
 }
示例#18
0
 public SecureMetaTable(MetaModel metaModel, TableProvider tableProvider, SecureMetaModel.GetVisibleColumns getVisibleColumns)
     : base(metaModel, tableProvider)
 {
     _getVisibleColumns = getVisibleColumns;
 }