/*
Kooboo is a content management system based on ASP.NET MVC framework. Copyright 2009 Yardi Technology Limited.
This program is free software: you can redistribute it and/or modify it under the terms of the
GNU General Public License version 3 as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program.
If not, see http://www.kooboo.com/gpl3/.
*/
using System;
using System.Web;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Linq.Expressions;
using System.Collections;
using Everest.CmsServices.MvcHelper;
namespace Everest.CmsServices.LINQ{
public abstract class ContentQueryable<T> : IQueryable<T>, IOrderedQueryable<T>
{
Expression expression;
public ContentQueryable()
{
this.expression = new StatementExpression(true, typeof(ContentQueryable<T>));
}
public ContentQueryable(Expression expression)
{
if (expression == null)
{
throw new ArgumentNullException("expression");
}
if (!typeof(IQueryable<T>).IsAssignableFrom(expression.Type))
{
throw new ArgumentOutOfRangeException("expression");
}
this.expression = expression;
}
#region IQueryable Members
public Type ElementType
{
get { return typeof(ContentContainer); }
}
public System.Linq.Expressions.Expression Expression
{
get { return expression; }
}
public abstract IQueryProvider Provider { get; }
public IEnumerator<T> GetEnumerator()
{
return ((IEnumerable<T>)this.Provider.Execute(this.expression)).GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator()
{
return ((IEnumerable)this.Provider.Execute(this.expression)).GetEnumerator();
}
#endregion
}
}
|