public DataServiceAssociationProvider(AssociationDirection direction,
     ColumnProvider fromColumn, TableProvider toTable, IList<String> foreignKeyNames) {
     Direction = direction;
     FromColumn = fromColumn;
     ToTable = toTable;
     ForeignKeyNames = new ReadOnlyCollection<string>(foreignKeyNames);
 }
コード例 #2
0
ファイル: SecureMetaModel.cs プロジェクト: weavver/data
 protected override MetaTable CreateTable(TableProvider provider)
 {
     if (_getVisibleColumns == null)
             return new SecureMetaTable(this, provider);
        else
             return new SecureMetaTable(this, provider, _getVisibleColumns);
 }
コード例 #3
0
        /// <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;
        }
コード例 #4
0
        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
ファイル: DLinqColumnProvider.cs プロジェクト: nobled/mono
		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;
		}
コード例 #6
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;
 }
コード例 #7
0
 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;
        }
コード例 #10
0
 private static DLinqColumnProvider FindColumn(TableProvider table, String columnName) {
     // 
     return (DLinqColumnProvider)table.Columns.First(member => member.Name.Equals(columnName));
 }
コード例 #11
0
 protected override MetaTable CreateTable(TableProvider provider) {
     return new CustomMetaTable(this, provider);
 }
コード例 #12
0
 public MetaTable(MetaModel metaModel, TableProvider tableProvider) {
     _tableProvider = tableProvider;
     Model = metaModel;
 }
コード例 #13
0
 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
ファイル: SecureMetaTable.cs プロジェクト: weavver/data
 public SecureMetaTable(MetaModel metaModel, TableProvider tableProvider)
     : base(metaModel, tableProvider)
 {
 }
コード例 #16
0
 private static DLinqColumnProvider FindColumn(TableProvider table, String columnName)
 {
     //
     return((DLinqColumnProvider)table.Columns.First(member => member.Name.Equals(columnName)));
 }
コード例 #17
0
 public CustomMetaTable(MetaModel metaModel, TableProvider tableProvider) :
     base(metaModel, tableProvider) {
 }
コード例 #18
0
ファイル: SecureMetaTable.cs プロジェクト: weavver/data
 public SecureMetaTable(MetaModel metaModel, TableProvider tableProvider, SecureMetaModel.GetVisibleColumns getVisibleColumns)
     : base(metaModel, tableProvider)
 {
     _getVisibleColumns = getVisibleColumns;
 }