コード例 #1
0
        /// <summary>
        /// Gets the current business object that is bound to
        /// the specified <see cref="GridViewRow"/> object.
        /// </summary>
        /// <param name="links">A collection of business objects.</param>
        /// <param name="row">A <see cref="GridViewRow"/> object.</param>
        /// <returns></returns>
        public Object GetLink(IList links, GridViewRow row)
        {
            String id = GetEntityKeyValue(row);

            return(EntityUtil.GetEntity(links, EntityKeyName, id));
        }
コード例 #2
0
ファイル: EntityFunctions.cs プロジェクト: dox0/DotNet471RS3
 public static System.DateTime? AddDays(System.DateTime? dateValue, System.Int32? addValue)
 {
     throw EntityUtil.NotSupported(System.Data.Entity.Strings.ELinq_EdmFunctionDirectCall);
 }
コード例 #3
0
ファイル: EntityFunctions.cs プロジェクト: dox0/DotNet471RS3
 public static System.TimeSpan? AddNanoseconds(System.TimeSpan? timeValue, System.Int32? addValue)
 {
     throw EntityUtil.NotSupported(System.Data.Entity.Strings.ELinq_EdmFunctionDirectCall);
 }
コード例 #4
0
ファイル: EntityFunctions.cs プロジェクト: dox0/DotNet471RS3
 public static System.Int32? GetTotalOffsetMinutes(System.DateTimeOffset? dateTimeOffsetArgument)
 {
     throw EntityUtil.NotSupported(System.Data.Entity.Strings.ELinq_EdmFunctionDirectCall);
 }
コード例 #5
0
ファイル: EntityFunctions.cs プロジェクト: dox0/DotNet471RS3
 public static System.DateTimeOffset? CreateDateTimeOffset(System.Int32? year, System.Int32? month, System.Int32? day, System.Int32? hour, System.Int32? minute, System.Double? second, System.Int32? timeZoneOffset)
 {
     throw EntityUtil.NotSupported(System.Data.Entity.Strings.ELinq_EdmFunctionDirectCall);
 }
コード例 #6
0
ファイル: EntityFunctions.cs プロジェクト: dox0/DotNet471RS3
 public static System.Int32? DiffNanoseconds(System.DateTime? timeValue1, System.DateTime? timeValue2)
 {
     throw EntityUtil.NotSupported(System.Data.Entity.Strings.ELinq_EdmFunctionDirectCall);
 }
コード例 #7
0
ファイル: EntityFunctions.cs プロジェクト: dox0/DotNet471RS3
 public static System.String Right(System.String stringArgument, System.Int64?length)
 {
     throw EntityUtil.NotSupported(System.Data.Entity.Strings.ELinq_EdmFunctionDirectCall);
 }
コード例 #8
0
 IOrderedEnumerable <TElement> IOrderedEnumerable <TElement> .CreateOrderedEnumerable <K>(Func <TElement, K> keySelector, IComparer <K> comparer, bool descending)
 {
     throw EntityUtil.NotSupported(System.Data.Entity.Strings.ELinq_CreateOrderedEnumerableNotSupported);
 }
コード例 #9
0
 public override ChangeNode Visit(DbCrossJoinExpression node)
 {
     throw EntityUtil.NotSupported(System.Data.Entity.Strings.Update_UnsupportedJoinType(node.ExpressionKind));
 }
コード例 #10
0
        /// <summary>
        /// Gets a collection of Entity objects based on the value of the SelectMethod property.
        /// </summary>
        /// <param name="count">The total number of rows in the DataSource.</param>
        /// <returns>A collection of Entity objects.</returns>
        protected override IList <ErrorLog> GetSelectData(out int count)
        {
            Hashtable        values       = CollectionsUtil.CreateCaseInsensitiveHashtable(GetParameterValues());
            Hashtable        customOutput = CollectionsUtil.CreateCaseInsensitiveHashtable();
            IList <ErrorLog> results      = null;
            ErrorLog         item;

            count = 0;

            System.Int32 _errorLogId;

            switch (SelectMethod)
            {
            case ErrorLogSelectMethod.Get:
                ErrorLogKey entityKey = new ErrorLogKey();
                entityKey.Load(values);
                item    = ErrorLogProvider.Get(entityKey);
                results = new TList <ErrorLog>();
                if (item != null)
                {
                    results.Add(item);
                }
                count = results.Count;
                break;

            case ErrorLogSelectMethod.GetAll:
                results = ErrorLogProvider.GetAll(StartIndex, PageSize, out count);
                break;

            case ErrorLogSelectMethod.GetPaged:
                results = ErrorLogProvider.GetPaged(WhereClause, OrderBy, PageIndex, PageSize, out count);
                break;

            case ErrorLogSelectMethod.Find:
                if (FilterParameters != null)
                {
                    results = ErrorLogProvider.Find(FilterParameters, OrderBy, StartIndex, PageSize, out count);
                }
                else
                {
                    results = ErrorLogProvider.Find(WhereClause, StartIndex, PageSize, out count);
                }
                break;

            // PK
            case ErrorLogSelectMethod.GetByErrorLogId:
                _errorLogId = (values["ErrorLogId"] != null) ? (System.Int32)EntityUtil.ChangeType(values["ErrorLogId"], typeof(System.Int32)) : (int)0;
                item        = ErrorLogProvider.GetByErrorLogId(_errorLogId);
                results     = new TList <ErrorLog>();
                if (item != null)
                {
                    results.Add(item);
                }
                count = results.Count;
                break;

            // IX
            // FK
            // M:M
            // Custom
            default:
                break;
            }

            if (results != null && count < 1)
            {
                count = results.Count;

                if (!String.IsNullOrEmpty(CustomMethodRecordCountParamName))
                {
                    object objCustomCount = EntityUtil.ChangeType(customOutput[CustomMethodRecordCountParamName], typeof(Int32));

                    if (objCustomCount != null)
                    {
                        count = (int)objCustomCount;
                    }
                }
            }

            return(results);
        }
コード例 #11
0
 public CompensatingCollection(IEnumerable <TElement> source)
 {
     _source     = EntityUtil.CheckArgumentNull(source, "source");
     _expression = Expression.Constant(source);
 }
コード例 #12
0
ファイル: RowType.cs プロジェクト: dox0/DotNet471RS3
 /// <summary>
 /// Adds a property
 /// </summary>
 /// <param name="property">The property to add</param>
 private void AddProperty(EdmProperty property)
 {
     EntityUtil.GenericCheckArgumentNull(property, "property");
     AddMember(property);
 }
コード例 #13
0
ファイル: ObjectQuery`.cs プロジェクト: jwanagel/jjwtest
        public new Task <ObjectResult <T> > ExecuteAsync(MergeOption mergeOption, CancellationToken cancellationToken)
        {
            EntityUtil.CheckArgumentMergeOption(mergeOption);

            return(GetResultsAsync(mergeOption, cancellationToken));
        }
コード例 #14
0
        /// <summary>
        /// Gets a collection of Entity objects based on the value of the SelectMethod property.
        /// </summary>
        /// <param name="count">The total number of rows in the DataSource.</param>
        /// <returns>A collection of Entity objects.</returns>
        protected override IList <Document> GetSelectData(out int count)
        {
            Hashtable        values       = CollectionsUtil.CreateCaseInsensitiveHashtable(GetParameterValues());
            Hashtable        customOutput = CollectionsUtil.CreateCaseInsensitiveHashtable();
            IList <Document> results      = null;
            Document         item;

            count = 0;

            System.String _fileName;
            System.String _revision;
            System.Int32  _documentId;
            System.Int32  _productId;

            switch (SelectMethod)
            {
            case DocumentSelectMethod.Get:
                DocumentKey entityKey = new DocumentKey();
                entityKey.Load(values);
                item    = DocumentProvider.Get(entityKey);
                results = new TList <Document>();
                if (item != null)
                {
                    results.Add(item);
                }
                count = results.Count;
                break;

            case DocumentSelectMethod.GetAll:
                results = DocumentProvider.GetAll(StartIndex, PageSize, out count);
                break;

            case DocumentSelectMethod.GetPaged:
                results = DocumentProvider.GetPaged(WhereClause, OrderBy, PageIndex, PageSize, out count);
                break;

            case DocumentSelectMethod.Find:
                if (FilterParameters != null)
                {
                    results = DocumentProvider.Find(FilterParameters, OrderBy, StartIndex, PageSize, out count);
                }
                else
                {
                    results = DocumentProvider.Find(WhereClause, StartIndex, PageSize, out count);
                }
                break;

            // PK
            case DocumentSelectMethod.GetByDocumentId:
                _documentId = (values["DocumentId"] != null) ? (System.Int32)EntityUtil.ChangeType(values["DocumentId"], typeof(System.Int32)) : (int)0;
                item        = DocumentProvider.GetByDocumentId(_documentId);
                results     = new TList <Document>();
                if (item != null)
                {
                    results.Add(item);
                }
                count = results.Count;
                break;

            // IX
            case DocumentSelectMethod.GetByFileNameRevision:
                _fileName = (values["FileName"] != null) ? (System.String)EntityUtil.ChangeType(values["FileName"], typeof(System.String)) : string.Empty;
                _revision = (values["Revision"] != null) ? (System.String)EntityUtil.ChangeType(values["Revision"], typeof(System.String)) : string.Empty;
                item      = DocumentProvider.GetByFileNameRevision(_fileName, _revision);
                results   = new TList <Document>();
                if (item != null)
                {
                    results.Add(item);
                }
                count = results.Count;
                break;

            // FK
            // M:M
            case DocumentSelectMethod.GetByProductIdFromProductDocument:
                _productId = (values["ProductId"] != null) ? (System.Int32)EntityUtil.ChangeType(values["ProductId"], typeof(System.Int32)) : (int)0;
                results    = DocumentProvider.GetByProductIdFromProductDocument(_productId, this.StartIndex, this.PageSize, out count);
                break;

            // Custom
            default:
                break;
            }

            if (results != null && count < 1)
            {
                count = results.Count;

                if (!String.IsNullOrEmpty(CustomMethodRecordCountParamName))
                {
                    object objCustomCount = EntityUtil.ChangeType(customOutput[CustomMethodRecordCountParamName], typeof(Int32));

                    if (objCustomCount != null)
                    {
                        count = (int)objCustomCount;
                    }
                }
            }

            return(results);
        }
コード例 #15
0
 /// <summary>
 ///   Adds a path to the set of navigation property span paths included in the results of this query
 /// </summary>
 /// <param name="path">The new span path</param>
 /// <returns>A new ObjectQuery that includes the specified span path</returns>
 public ObjectQuery <T> Include(string path)
 {
     EntityUtil.CheckStringArgument(path, "path");
     return(new ObjectQuery <T>(this.QueryState.Include(this, path)));
 }
コード例 #16
0
        /// <summary>
        /// Gets a collection of Entity objects based on the value of the SelectMethod property.
        /// </summary>
        /// <param name="count">The total number of rows in the DataSource.</param>
        /// <returns>A collection of Entity objects.</returns>
        protected override IList <SalesTerritoryHistory> GetSelectData(out int count)
        {
            Hashtable values       = CollectionsUtil.CreateCaseInsensitiveHashtable(GetParameterValues());
            Hashtable customOutput = CollectionsUtil.CreateCaseInsensitiveHashtable();
            IList <SalesTerritoryHistory> results = null;
            SalesTerritoryHistory         item;

            count = 0;

            System.Guid     _rowguid;
            System.Int32    _salesPersonId;
            System.DateTime _startDate;
            System.Int32    _territoryId;

            switch (SelectMethod)
            {
            case SalesTerritoryHistorySelectMethod.Get:
                SalesTerritoryHistoryKey entityKey = new SalesTerritoryHistoryKey();
                entityKey.Load(values);
                item    = SalesTerritoryHistoryProvider.Get(entityKey);
                results = new TList <SalesTerritoryHistory>();
                if (item != null)
                {
                    results.Add(item);
                }
                count = results.Count;
                break;

            case SalesTerritoryHistorySelectMethod.GetAll:
                results = SalesTerritoryHistoryProvider.GetAll(StartIndex, PageSize, out count);
                break;

            case SalesTerritoryHistorySelectMethod.GetPaged:
                results = SalesTerritoryHistoryProvider.GetPaged(WhereClause, OrderBy, PageIndex, PageSize, out count);
                break;

            case SalesTerritoryHistorySelectMethod.Find:
                if (FilterParameters != null)
                {
                    results = SalesTerritoryHistoryProvider.Find(FilterParameters, OrderBy, StartIndex, PageSize, out count);
                }
                else
                {
                    results = SalesTerritoryHistoryProvider.Find(WhereClause, StartIndex, PageSize, out count);
                }
                break;

            // PK
            case SalesTerritoryHistorySelectMethod.GetBySalesPersonIdStartDateTerritoryId:
                _salesPersonId = (values["SalesPersonId"] != null) ? (System.Int32)EntityUtil.ChangeType(values["SalesPersonId"], typeof(System.Int32)) : (int)0;
                _startDate     = (values["StartDate"] != null) ? (System.DateTime)EntityUtil.ChangeType(values["StartDate"], typeof(System.DateTime)) : DateTime.MinValue;
                _territoryId   = (values["TerritoryId"] != null) ? (System.Int32)EntityUtil.ChangeType(values["TerritoryId"], typeof(System.Int32)) : (int)0;
                item           = SalesTerritoryHistoryProvider.GetBySalesPersonIdStartDateTerritoryId(_salesPersonId, _startDate, _territoryId);
                results        = new TList <SalesTerritoryHistory>();
                if (item != null)
                {
                    results.Add(item);
                }
                count = results.Count;
                break;

            // IX
            case SalesTerritoryHistorySelectMethod.GetByRowguid:
                _rowguid = (values["Rowguid"] != null) ? (System.Guid)EntityUtil.ChangeType(values["Rowguid"], typeof(System.Guid)) : Guid.Empty;
                item     = SalesTerritoryHistoryProvider.GetByRowguid(_rowguid);
                results  = new TList <SalesTerritoryHistory>();
                if (item != null)
                {
                    results.Add(item);
                }
                count = results.Count;
                break;

            // FK
            case SalesTerritoryHistorySelectMethod.GetBySalesPersonId:
                _salesPersonId = (values["SalesPersonId"] != null) ? (System.Int32)EntityUtil.ChangeType(values["SalesPersonId"], typeof(System.Int32)) : (int)0;
                results        = SalesTerritoryHistoryProvider.GetBySalesPersonId(_salesPersonId, this.StartIndex, this.PageSize, out count);
                break;

            case SalesTerritoryHistorySelectMethod.GetByTerritoryId:
                _territoryId = (values["TerritoryId"] != null) ? (System.Int32)EntityUtil.ChangeType(values["TerritoryId"], typeof(System.Int32)) : (int)0;
                results      = SalesTerritoryHistoryProvider.GetByTerritoryId(_territoryId, this.StartIndex, this.PageSize, out count);
                break;

            // M:M
            // Custom
            default:
                break;
            }

            if (results != null && count < 1)
            {
                count = results.Count;

                if (!String.IsNullOrEmpty(CustomMethodRecordCountParamName))
                {
                    object objCustomCount = EntityUtil.ChangeType(customOutput[CustomMethodRecordCountParamName], typeof(Int32));

                    if (objCustomCount != null)
                    {
                        count = (int)objCustomCount;
                    }
                }
            }

            return(results);
        }
コード例 #17
0
        // <summary>
        // Requires: record must have correct type for this metadata instance.
        // Populates a new <see cref="PropagatorResult" /> object representing a member of a record matching the
        // type of this extractor. Given a record and a member, this method wraps the value of the member
        // in a PropagatorResult. This operation can be performed efficiently by this class, which knows
        // important stuff about the type being extracted.
        // </summary>
        // <param name="stateEntry"> state manager entry containing value (used for error reporting) </param>
        // <param name="record"> Record containing value (used to find the actual value) </param>
        // <param name="useCurrentValues"> Indicates whether we are reading current or original values. </param>
        // <param name="key"> Entity key for the state entry. Must be set for entity records. </param>
        // <param name="ordinal"> Ordinal of Member for which to retrieve a value. </param>
        // <param name="modifiedPropertiesBehavior"> Indicates how to determine whether a property is modified. </param>
        // <returns> Propagator result describing this member value. </returns>
        internal PropagatorResult RetrieveMember(
            IEntityStateEntry stateEntry, IExtendedDataRecord record, bool useCurrentValues,
            EntityKey key, int ordinal, ModifiedPropertiesBehavior modifiedPropertiesBehavior)
        {
            var memberInformation = m_memberMap[ordinal];

            // get identifier value
            int identifier;

            if (memberInformation.IsKeyMember)
            {
                // retrieve identifier for this key member
                Debug.Assert(
                    null != (object)key, "entities must have keys, and only entity members are marked IsKeyMember by " +
                    "the metadata wrapper");
                var keyOrdinal = memberInformation.EntityKeyOrdinal.Value;
                identifier = m_translator.KeyManager.GetKeyIdentifierForMemberOffset(key, keyOrdinal, ((EntityType)m_type).KeyMembers.Count);
            }
            else if (memberInformation.IsForeignKeyMember)
            {
                identifier = m_translator.KeyManager.GetKeyIdentifierForMember(key, record.GetName(ordinal), useCurrentValues);
            }
            else
            {
                identifier = PropagatorResult.NullIdentifier;
            }

            // determine if the member is modified
            var isModified = modifiedPropertiesBehavior == ModifiedPropertiesBehavior.AllModified ||
                             (modifiedPropertiesBehavior == ModifiedPropertiesBehavior.SomeModified &&
                              stateEntry.ModifiedProperties != null &&
                              stateEntry.ModifiedProperties[memberInformation.Ordinal]);

            // determine member value
            Debug.Assert(record.GetName(ordinal) == memberInformation.Member.Name, "expect record to present properties in metadata order");
            if (memberInformation.CheckIsNotNull &&
                record.IsDBNull(ordinal))
            {
                throw EntityUtil.Update(Strings.Update_NullValue(record.GetName(ordinal)), null, stateEntry);
            }
            var value = record.GetValue(ordinal);

            // determine what kind of member this is

            // entityKey (association end)
            var entityKey = value as EntityKey;

            if (null != (object)entityKey)
            {
                return(CreateEntityKeyResult(stateEntry, entityKey));
            }

            // record (nested complex type)
            var nestedRecord = value as IExtendedDataRecord;

            if (null != nestedRecord)
            {
                // for structural types, we track whether the entire complex type value is modified or not
                var nestedModifiedPropertiesBehavior = isModified
                                                           ? ModifiedPropertiesBehavior.AllModified
                                                           : ModifiedPropertiesBehavior.NoneModified;
                var translator = m_translator;

                return(ExtractResultFromRecord(
                           stateEntry, isModified, nestedRecord, useCurrentValues, translator, nestedModifiedPropertiesBehavior));
            }

            // simple value (column/property value)
            return(CreateSimpleResult(stateEntry, record, memberInformation, identifier, isModified, ordinal, value));
        }
コード例 #18
0
        /// <summary>
        ///     Return a list suitable for data binding using the supplied EntityCollection
        /// </summary>
        /// <typeparam name="TElement"> CLR type of the elements of the EntityCollection. </typeparam>
        /// <param name="entityType"> The EntityType of the elements in the collection. This should either be the same as the EntityType that corresponds to the CLR TElement type, or a EntityType derived from the declared EntityCollection element type. </param>
        /// <param name="entityCollection"> The EntityCollection from which a binding list is created. </param>
        /// <returns>
        ///     <see cref="IBindingList" /> that is suitable for data binding.
        /// </returns>
        internal static IBindingList CreateViewForEntityCollection <TElement>(
            EntityType entityType, EntityCollection <TElement> entityCollection)
            where TElement : class
        {
            Type clrElementType         = null;
            var  entityTypeUsage        = entityType == null ? null : TypeUsage.Create(entityType);
            var  ospaceElementTypeUsage = GetOSpaceTypeUsage(entityTypeUsage, entityCollection.ObjectContext);

            // Map the O-Space EDM type to a CLR type.
            // If the mapping is unsuccessful, fallback to TElement type.
            if (ospaceElementTypeUsage == null)
            {
                clrElementType = typeof(TElement);
            }
            else
            {
                clrElementType = GetClrType <TElement>(ospaceElementTypeUsage.EdmType);

                // A null clrElementType is returned by GetClrType if the EDM type is a RowType with no specific CLR type mapping.
                // This should not happen when working with EntityCollections, but if it does, fallback to TEntityRef type.
                Debug.Assert(clrElementType != null, "clrElementType has unexpected value of null.");

                if (clrElementType == null)
                {
                    clrElementType = typeof(TElement);
                }
            }

            IBindingList objectView;

            // If the clrElementType matches the declared TElement type, optimize the construction of the ObjectView
            // by avoiding a reflection-based instantiation.
            if (clrElementType == typeof(TElement))
            {
                var viewData = new ObjectViewEntityCollectionData <TElement, TElement>(entityCollection);
                objectView = new ObjectView <TElement>(viewData, entityCollection);
            }
            else
            {
                if (!typeof(TElement).IsAssignableFrom(clrElementType))
                {
                    throw EntityUtil.ValueInvalidCast(clrElementType, typeof(TElement));
                }

                // Use reflection to create an instance of the generic ObjectView and ObjectViewEntityCollectionData classes,
                // using clrElementType as the value of TElement generic type parameter for both classes.

                var objectViewDataType = _genericObjectViewEntityCollectionDataType.MakeGenericType(clrElementType, typeof(TElement));

                var viewDataConstructor = objectViewDataType.GetConstructor(
                    BindingFlags.Instance | BindingFlags.NonPublic,
                    null,
                    new[] { typeof(EntityCollection <TElement>) },
                    null);

                Debug.Assert(
                    viewDataConstructor != null,
                    "ObjectViewEntityCollectionData constructor not found. Please ensure constructor signature is correct.");

                // Create ObjectViewEntityCollectionData instance
                var viewData = viewDataConstructor.Invoke(new object[] { entityCollection });

                // Create ObjectView instance
                objectView = CreateObjectView(clrElementType, objectViewDataType, viewData, entityCollection);
            }

            return(objectView);
        }
コード例 #19
0
ファイル: EntityFunctions.cs プロジェクト: dox0/DotNet471RS3
 public static System.Decimal? Truncate(System.Decimal? value, System.Int32? digits)
 {
     throw EntityUtil.NotSupported(System.Data.Entity.Strings.ELinq_EdmFunctionDirectCall);
 }
コード例 #20
0
        /// <summary>
        ///     Return a list suitable for data binding using the supplied query results.
        /// </summary>
        /// <typeparam name="TElement"> CLR type of query result elements declared by the caller. </typeparam>
        /// <param name="elementEdmTypeUsage"> The EDM type of the query results, used as the primary means of determining the CLR type of list returned by this method. </param>
        /// <param name="queryResults"> IEnumerable used to enumerate query results used to populate binding list. Must not be null. </param>
        /// <param name="objectContext">
        ///     <see cref="ObjectContext" /> associated with the query from which results were obtained. Must not be null.
        /// </param>
        /// <param name="forceReadOnly">
        ///     <b>True</b> to prevent modifications to the binding list built from the query result; otherwise <b>false</b> . Note that other conditions may prevent the binding list from being modified, so a value of <b>false</b> supplied for this parameter doesn't necessarily mean that the list will be writable.
        /// </param>
        /// <param name="singleEntitySet">
        ///     If the query results are composed of entities that only exist in a single
        ///     <see
        ///         cref="EntitySet" />
        ///     , the value of this parameter is the single EntitySet. Otherwise the value of this parameter should be null.
        /// </param>
        /// <returns>
        ///     <see cref="IBindingList" /> that is suitable for data binding.
        /// </returns>
        internal static IBindingList CreateViewForQuery <TElement>(
            TypeUsage elementEdmTypeUsage, IEnumerable <TElement> queryResults, ObjectContext objectContext, bool forceReadOnly,
            EntitySet singleEntitySet)
        {
            DebugCheck.NotNull(queryResults);
            DebugCheck.NotNull(objectContext);

            Type clrElementType         = null;
            var  ospaceElementTypeUsage = GetOSpaceTypeUsage(elementEdmTypeUsage, objectContext);

            // Map the O-Space EDM type to a CLR type.
            // If the mapping is unsuccessful, fallback to TElement type.
            if (ospaceElementTypeUsage == null)
            {
                clrElementType = typeof(TElement);
            }
            {
                clrElementType = GetClrType <TElement>(ospaceElementTypeUsage.EdmType);
            }

            IBindingList objectView;
            object       eventDataSource = objectContext.ObjectStateManager;

            // If the clrElementType matches the declared TElement type, optimize the construction of the ObjectView
            // by avoiding a reflection-based instantiation.
            if (clrElementType == typeof(TElement))
            {
                var viewData = new ObjectViewQueryResultData <TElement>(queryResults, objectContext, forceReadOnly, singleEntitySet);

                objectView = new ObjectView <TElement>(viewData, eventDataSource);
            }
            else if (clrElementType == null)
            {
                var viewData = new ObjectViewQueryResultData <DbDataRecord>(queryResults, objectContext, true, null);
                objectView = new DataRecordObjectView(viewData, eventDataSource, (RowType)ospaceElementTypeUsage.EdmType, typeof(TElement));
            }
            else
            {
                if (!typeof(TElement).IsAssignableFrom(clrElementType))
                {
                    throw EntityUtil.ValueInvalidCast(clrElementType, typeof(TElement));
                }

                // Use reflection to create an instance of the generic ObjectView and ObjectViewQueryResultData classes,
                // using clrElementType as the value of TElement generic type parameter for both classes.

                var objectViewDataType = _genericObjectViewQueryResultDataType.MakeGenericType(clrElementType);

                var viewDataConstructor = objectViewDataType.GetConstructor(
                    BindingFlags.Instance | BindingFlags.NonPublic,
                    null,
                    new[] { typeof(IEnumerable), typeof(ObjectContext), typeof(bool), typeof(EntitySet) },
                    null);

                Debug.Assert(
                    viewDataConstructor != null,
                    "ObjectViewQueryResultData constructor not found. Please ensure constructor signature is correct.");

                // Create ObjectViewQueryResultData instance
                var viewData = viewDataConstructor.Invoke(new object[] { queryResults, objectContext, forceReadOnly, singleEntitySet });

                // Create ObjectView instance
                objectView = CreateObjectView(clrElementType, objectViewDataType, viewData, eventDataSource);
            }

            return(objectView);
        }
コード例 #21
0
ファイル: EntityFunctions.cs プロジェクト: dox0/DotNet471RS3
 public static System.String Reverse(System.String stringArgument)
 {
     throw EntityUtil.NotSupported(System.Data.Entity.Strings.ELinq_EdmFunctionDirectCall);
 }
コード例 #22
0
        [ResourceConsumption(ResourceScope.Machine)] //For Path.GetFullPath method call. But the path is not created in this method.
        static internal string NormalizeFilePaths(string path)
        {
            bool getFullPath = true;    // used to determine whether we need to invoke GetFullPath()

            if (!String.IsNullOrEmpty(path))
            {
                path = path.Trim();

                // If the path starts with a '~' character, try to resolve it as a Web/ASP.NET
                // application path.
                //
                if (path.StartsWith(EdmConstants.WebHomeSymbol, StringComparison.Ordinal))
                {
                    AspProxy aspProxy = new AspProxy();
                    path        = aspProxy.MapWebPath(path);
                    getFullPath = false;
                }

                if (path.Length == 2 && path[1] == System.IO.Path.VolumeSeparatorChar)
                {
                    path = path + System.IO.Path.DirectorySeparatorChar;
                }
                else
                {
                    // See if the path contains the |DataDirectory| macro that we need to
                    // expand. Note that ExpandDataDirectory() won't process the path unless
                    // it begins with the macro.
                    //
                    string fullPath = System.Data.EntityClient.DbConnectionOptions.ExpandDataDirectory(
                        System.Data.EntityClient.EntityConnectionStringBuilder.MetadataParameterName,       // keyword ("Metadata")
                        path                                                                                // value
                        );

                    // ExpandDataDirectory() returns null if it doesn't find the macro in its
                    // argument.
                    //
                    if (fullPath != null)
                    {
                        path        = fullPath;
                        getFullPath = false;
                    }
                }
            }
            try
            {
                if (getFullPath)
                {
                    path = System.IO.Path.GetFullPath(path);
                }
            }
            catch (ArgumentException e)
            {
                throw EntityUtil.Metadata(System.Data.Entity.Strings.NotValidInputPath, e);
            }
            catch (NotSupportedException e)
            {
                throw EntityUtil.Metadata(System.Data.Entity.Strings.NotValidInputPath, e);
            }
            catch (PathTooLongException)
            {
                throw EntityUtil.Metadata(System.Data.Entity.Strings.NotValidInputPath);
            }

            return(path);
        }
コード例 #23
0
ファイル: EntityFunctions.cs プロジェクト: dox0/DotNet471RS3
 public static System.DateTime? TruncateTime(System.DateTime? dateValue)
 {
     throw EntityUtil.NotSupported(System.Data.Entity.Strings.ELinq_EdmFunctionDirectCall);
 }
コード例 #24
0
 // Intended for use only in the MethodCallExpression produced for inline queries.
 internal ObjectQuery <T> MergeAs(MergeOption mergeOption)
 {
     throw EntityUtil.InvalidOperation(Strings.ELinq_MethodNotDirectlyCallable);
 }
コード例 #25
0
ファイル: EntityFunctions.cs プロジェクト: dox0/DotNet471RS3
 public static System.TimeSpan? CreateTime(System.Int32? hour, System.Int32? minute, System.Double? second)
 {
     throw EntityUtil.NotSupported(System.Data.Entity.Strings.ELinq_EdmFunctionDirectCall);
 }
コード例 #26
0
 // Intended for use only in the MethodCallExpression produced for inline queries.
 internal ObjectQuery <T> IncludeSpan(Span span)
 {
     throw EntityUtil.InvalidOperation(Strings.ELinq_MethodNotDirectlyCallable);
 }
コード例 #27
0
ファイル: EntityFunctions.cs プロジェクト: dox0/DotNet471RS3
 public static System.DateTimeOffset? AddMilliseconds(System.DateTimeOffset? timeValue, System.Int32? addValue)
 {
     throw EntityUtil.NotSupported(System.Data.Entity.Strings.ELinq_EdmFunctionDirectCall);
 }
コード例 #28
0
 /// <summary>
 ///   This method allows explicit query evaluation with a specified merge
 ///   option which will override the merge option property.
 /// </summary>
 /// <param name="mergeOption">
 ///   The MergeOption to use when executing the query.
 /// </param>
 /// <returns>
 ///   An enumerable for the ObjectQuery results.
 /// </returns>
 public new ObjectResult <T> Execute(MergeOption mergeOption)
 {
     EntityUtil.CheckArgumentMergeOption(mergeOption);
     return(this.GetResults(mergeOption));
 }
コード例 #29
0
ファイル: EntityFunctions.cs プロジェクト: dox0/DotNet471RS3
 public static System.Int32? DiffMonths(System.DateTimeOffset? dateValue1, System.DateTimeOffset? dateValue2)
 {
     throw EntityUtil.NotSupported(System.Data.Entity.Strings.ELinq_EdmFunctionDirectCall);
 }
コード例 #30
0
 /// <summary>
 /// Gets the unique identifier value for the specified business object.
 /// </summary>
 /// <param name="entity"></param>
 /// <returns></returns>
 public Object GetEntityId(Object entity)
 {
     return(EntityUtil.GetPropertyValue(entity, EntityKeyName));
 }