/// <summary> /// Given a data source column name, returns the corresponding Entity-SQL. If /// we are using the wrapper, we defer to the property descriptor to get /// the string. If there is no wrapper (or no corresponding property descriptor) /// we use the column name directly. /// </summary> /// <param name="columnName">Column name for which we produce a value expression.</param> /// <returns>Entity-SQL for column.</returns> internal static string GetEntitySqlValueForColumnName(string columnName, EntityDataSourceWrapperCollection wrapperCollection) { Debug.Assert(!String.IsNullOrEmpty(columnName), "columnName must be given"); string result = null; if (wrapperCollection != null) { // use wrapper definition if it is available EntityDataSourceWrapperPropertyDescriptor descriptor = wrapperCollection.GetItemProperties(null).Find(columnName, false) as EntityDataSourceWrapperPropertyDescriptor; if (null != descriptor) { result = descriptor.Column.GetEntitySqlValue(); } } // if descriptor does not provide SQL, create the default: it._columnName_ if (null == result) { result = EntitySqlElementAlias + "." + QuoteEntitySqlIdentifier(columnName); } return(result); }
internal EntityDataSourceWrapperPropertyDescriptor(EntityDataSourceWrapperCollection collection, EntityDataSourceColumn column) : base(EntityDataSourceUtil.CheckArgumentNull(column, "column").DisplayName, new Attribute[] { }) { EntityDataSourceUtil.CheckArgumentNull(collection, "collection"); _collection = collection; _column = column; }
internal EntityDataSourceWrapper(EntityDataSourceWrapperCollection collection, object trackedEntity) { EntityDataSourceUtil.CheckArgumentNull(collection, "collection"); EntityDataSourceUtil.CheckArgumentNull(trackedEntity, "trackedEntity"); this._collection = collection; // retrieve state entry if (!this._collection.Context.ObjectStateManager.TryGetObjectStateEntry(trackedEntity, out _stateEntry)) { throw new ArgumentException(Strings.ComponentNotFromProperCollection, "trackedEntity"); } }
internal OrderByBuilder(string argsSortExpression, EntityDataSourceWrapperCollection wrapperCollection, string orderBy, bool autoGenerateOrderByClause, ParameterCollection orderByParameters, bool generateDefaultOrderByClause, EntityDataSource owner) { _argsSortExpression = argsSortExpression; _wrapperCollection = wrapperCollection; _orderBy = orderBy; _autoGenerateOrderByClause = autoGenerateOrderByClause; _orderByParameters = orderByParameters; _owner = owner; _generateDefaultOrderByClause = generateDefaultOrderByClause; }
/// <summary> /// Indicates whether the given property name exists on the result. /// The result could be indicated by a wrapperCollection, an entitySet or a typeUsage, /// any of which could be null. /// </summary> /// <param name="propertyName"></param> /// <param name="wrapperCollection"></param> /// <param name="entitySet"></param> /// <param name="tu"></param> /// <returns></returns> internal static bool PropertyIsOnEntity(string propertyName, EntityDataSourceWrapperCollection wrapperCollection, EntitySet entitySet, TypeUsage tu) { bool propertyIsOnEntity = false; if (null != wrapperCollection) { // check for descriptor if (null != wrapperCollection.GetItemProperties(null).Find(propertyName, /*ignoreCase*/ false)) { propertyIsOnEntity = true; } } if (null != tu) { ReadOnlyMetadataCollection <EdmMember> members = null; switch (tu.EdmType.BuiltInTypeKind) { case BuiltInTypeKind.RowType: members = ((RowType)(tu.EdmType)).Members; break; case BuiltInTypeKind.EntityType: members = ((EntityType)(tu.EdmType)).Members; break; } if (null != members && members.Contains(propertyName)) { propertyIsOnEntity = true; } } if (null != entitySet) { if (((EntityType)(entitySet.ElementType)).Members.Contains(propertyName)) { propertyIsOnEntity = true; } } return(propertyIsOnEntity); }
internal EntityDataSourceViewSchema(EntityDataSourceWrapperCollection wrappers) { DataColumn column; List<DataColumn> keys = new List<DataColumn>(); PropertyDescriptorCollection properties = wrappers.GetItemProperties(null); MetadataWorkspace workspace = wrappers.Context.MetadataWorkspace; foreach (EntityDataSourceWrapperPropertyDescriptor property in properties) { Type propertyType = property.PropertyType; column = ConstructColumn(property); column.AllowDBNull = property.Column.IsNullable; EntityDataSourcePropertyColumn propertyColumn = property.Column as EntityDataSourcePropertyColumn; if (null!= propertyColumn && propertyColumn.IsKey) { keys.Add(column); } Columns.Add(column); } this.PrimaryKey = keys.ToArray(); }
internal EntityDataSourceViewSchema(EntityDataSourceWrapperCollection wrappers) { DataColumn column; List <DataColumn> keys = new List <DataColumn>(); PropertyDescriptorCollection properties = wrappers.GetItemProperties(null); MetadataWorkspace workspace = wrappers.Context.MetadataWorkspace; foreach (EntityDataSourceWrapperPropertyDescriptor property in properties) { Type propertyType = property.PropertyType; column = ConstructColumn(property); column.AllowDBNull = property.Column.IsNullable; EntityDataSourcePropertyColumn propertyColumn = property.Column as EntityDataSourcePropertyColumn; if (null != propertyColumn && propertyColumn.IsKey) { keys.Add(column); } Columns.Add(column); } this.PrimaryKey = keys.ToArray(); }