2017-03-17 95 views
-2

我檢查大會EntityFramework.dll的元數據,v6.0.0.0,$ EntityFramework.dll $ v4.0.30319 $ NoDynamic \ System.Data.Entity.Infrastructure.DbQuery.cs怎樣的DBQuery <TResult>實現IEnumerable <TResult>

using System; 
using System.Collections; 
using System.ComponentModel; 
using System.Diagnostics.CodeAnalysis; 
using System.Linq; 

namespace System.Data.Entity.Infrastructure 
{ 
    // Summary: 
    //  Represents a non-generic LINQ to Entities query against a DbContext. 
    [SuppressMessage("Microsoft.Design", "CA1010:CollectionsShouldImplementGenericInterface")] 
    [SuppressMessage("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix")] 
    public abstract class DbQuery : IOrderedQueryable, IQueryable, IEnumerable, IListSource, IDbAsyncEnumerable 
    { 
     // Summary: 
     //  The IQueryable element type. 
     public virtual Type ElementType { get; } 

     // Summary: 
     //  Returns a new query where the entities returned will not be cached in the 
     //  System.Data.Entity.DbContext. 
     // 
     // Returns: 
     //  A new query with NoTracking applied. 
     public virtual DbQuery AsNoTracking(); 
     // 
     // Summary: 
     //  Returns a new query that will stream the results instead of buffering. 
     // 
     // Returns: 
     //  A new query with AsStreaming applied. 
     [Obsolete("Queries are now streaming by default unless a retrying ExecutionStrategy is used. Calling this method will have no effect.")] 
     public virtual DbQuery AsStreaming(); 
     // 
     // Summary: 
     //  Returns the equivalent generic System.Data.Entity.Infrastructure.DbQuery<TResult> 
     //  object. 
     // 
     // Type parameters: 
     // TElement: 
     //  The type of element for which the query was created. 
     // 
     // Returns: 
     //  The generic set object. 
     public DbQuery<TElement> Cast<TElement>(); 
     // 
     [EditorBrowsable(EditorBrowsableState.Never)] 
     public override bool Equals(object obj); 
     // 
     [EditorBrowsable(EditorBrowsableState.Never)] 
     public override int GetHashCode(); 
     // 
     [EditorBrowsable(EditorBrowsableState.Never)] 
     [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] 
     public Type GetType(); 
     // 
     // Summary: 
     //  Specifies the related objects to include in the query results. 
     // 
     // Parameters: 
     // path: 
     //  The dot-separated list of related objects to return in the query results. 
     // 
     // Returns: 
     //  A new DbQuery<T> with the defined query path. 
     // 
     // Remarks: 
     //  Paths are all-inclusive. For example, if an include call indicates Include("Orders.OrderLines"), 
     //  not only will OrderLines be included, but also Orders. When you call the 
     //  Include method, the query path is only valid on the returned instance of 
     //  the DbQuery<T>. Other instances of DbQuery<T> and the object context itself 
     //  are not affected. Because the Include method returns the query object, you 
     //  can call this method multiple times on an DbQuery<T> to specify multiple 
     //  paths for the query. 
     public virtual DbQuery Include(string path); 
     // 
     // Summary: 
     //  Returns a System.String representation of the underlying query. 
     // 
     // Returns: 
     //  The query string. 
     public override string ToString(); 
    } 
} 

但我沒有找到GetEnumerator()方法。這是如何發生的?

回答

1

它明確地實施......從codeplex

#region IEnumerable 

/// <summary> 
/// Returns an <see cref="IEnumerator{TElement}" /> which when enumerated will execute the query against the database. 
/// </summary> 
/// <returns> The query results. </returns> 
[SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")] 
IEnumerator<TResult> IEnumerable<TResult>.GetEnumerator() 
{ 
    ... 
} 

/// <summary> 
/// Returns an <see cref="IEnumerator{TElement}" /> which when enumerated will execute the query against the database. 
/// </summary> 
/// <returns> The query results. </returns> 
[SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")] 
IEnumerator IEnumerable.GetEnumerator() 
{ 
    ... 
} 

#endregion 

啊......只是注意到...您正在尋找在錯誤的文件.. I am checking the metadata of Assembly EntityFramework.dll, v6.0.0.0, $EntityFramework.dll$v4.0.30319$NoDynamic\System.Data.Entity.Infrastructure.**DbQuery.cs**用於abstract class DbQuery,而不用於class DbQuery<TResult>。作爲abstract class,它可能不完整(不實現所有接口)。你應該看看DbQuery`.cs文件

+0

謝謝。儘管鏈接確實證明它已經實施,但你解釋了爲什麼我沒有看到它。 – Yiping

相關問題