我檢查大會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()方法。這是如何發生的?
謝謝。儘管鏈接確實證明它已經實施,但你解釋了爲什麼我沒有看到它。 – Yiping