//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// Microsoft
// Microsoft
//------------------------------------------------------------------------------
namespace System.Data.Common.Internal.Materialization
{
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
///
/// What we return from our materialization of a collection column must be
/// exactly the type that the compilers expected when they generated the
/// code that asked for it. This class wraps our enumerators and derives
/// from all the possible options, covering all the bases.
///
internal class CompensatingCollection : IOrderedQueryable, IOrderedEnumerable
{
#region private state
///
/// The thing we're compensating for
///
private readonly IEnumerable _source;
///
/// An expression that returns the source as a constant
///
private readonly Expression _expression;
#endregion
#region constructors
public CompensatingCollection(IEnumerable source)
{
_source = EntityUtil.CheckArgumentNull(source, "source");
_expression = Expression.Constant(source);
}
#endregion
#region IEnumerable Members
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
{
return _source.GetEnumerator();
}
#endregion
#region IEnumerable Members
IEnumerator IEnumerable.GetEnumerator()
{
return _source.GetEnumerator();
}
#endregion
#region IOrderedEnumerable Members
IOrderedEnumerable IOrderedEnumerable.CreateOrderedEnumerable(Func keySelector, IComparer comparer, bool descending)
{
throw EntityUtil.NotSupported(System.Data.Entity.Strings.ELinq_CreateOrderedEnumerableNotSupported);
}
#endregion
#region IQueryable Members
Type IQueryable.ElementType
{
get { return typeof(TElement); }
}
Expression IQueryable.Expression
{
get { return _expression; }
}
IQueryProvider IQueryable.Provider
{
get
{
throw EntityUtil.NotSupported(System.Data.Entity.Strings.ELinq_UnsupportedQueryableMethod);
}
}
#endregion
#region IQueryable Members
#endregion
}
}