internal static string ParseWhere(this ODataQueryOptions options)
        {
            var where = string.Empty;
            if (options.Filter != null)
            {
                where = SQLFilterBinder.BindFilterQueryOption(options.Filter.FilterClause, options.Context.Model);
            }

            var dateTimeStamp = string.Empty;

            if (options.Request.Headers.ContainsKey("DateTimeStamp"))
            {
                var dateTimeStampHeader = options.Request.Headers.FirstOrDefault(r => r.Key.ToLower() == "datetimestamp").Value;
                dateTimeStamp = "CONVERT(BIGINT,DateTimeStamp)>" + dateTimeStampHeader;
            }

            if (string.IsNullOrEmpty(where))
            {
                where = dateTimeStamp;
            }
            else if (!string.IsNullOrEmpty(dateTimeStamp))
            {
                where = string.Format("({0}) and ({1})", dateTimeStamp, where);
            }

            if (!string.IsNullOrEmpty(where))
            {
                where = " where " + where;
            }
            return(where);
        }
 public static string BindFilterQueryOption(FilterQueryOption filterQuery)
 {
     if (filterQuery != null)
     {
         SQLFilterBinder binder = new SQLFilterBinder(filterQuery.Context.Model);
         return(binder.BindFilter(filterQuery) + Environment.NewLine);
     }
     return(string.Empty);
 }
        public static string BindFilterQueryOption(FilterClause filterClause, IEdmModel model)
        {
            if (filterClause == null || model == null)
            {
                return(string.Empty);
            }
            SQLFilterBinder binder = new SQLFilterBinder(model);

            return(binder.BindFilterClause(filterClause) + Environment.NewLine);
        }
        internal static string ParseWhere(this ExpandedNavigationSelectItem expanded, string condition, EdmModel model)
        {
            string where = SQLFilterBinder.BindFilterQueryOption(expanded.FilterOption, model);
            if (string.IsNullOrEmpty(where))
            {
                where = condition;
            }
            else if (!string.IsNullOrEmpty(condition))
            {
                where = string.Format("({0}) and ({1})", condition, where);
            }

            if (!string.IsNullOrEmpty(where))
            {
                where = " where " + where;
            }
            return(where);
        }