protected internal virtual void OnSelect(LinqToSqlDataSourceEventArgs <TEntity> args)
 {
     if (Select != null)
     {
         Select(this, args);
     }
 }
        protected override IEnumerable ExecuteSelect(DataSourceSelectArguments arguments)
        {
            _arguments = arguments;

            LinqToSqlDataSourceEventArgs <TEntity> eventArgs = new LinqToSqlDataSourceEventArgs <TEntity>
            {
                Query = _owner.DataContext.GetTable <TEntity>()
            };

            _owner.OnSelect(eventArgs);

            if (eventArgs.Query == null)
            {
                eventArgs.Query = _owner.DataContext.GetTable <TEntity>();
            }

            IEnumerable <TEntity> result = (eventArgs.QueryExpr != null) ? eventArgs.Query.Where(eventArgs.QueryExpr) : eventArgs.Query;

            arguments.TotalRowCount = result.Count();
            if (arguments.MaximumRows > 0 && arguments.StartRowIndex >= 0)
            {
                return(result.Skip(arguments.StartRowIndex).Take(arguments.MaximumRows));
            }
            else
            {
                return(result);
            }
        }