I am getting non static method requires a target error, and when I googled it I have seen posts to check null values and in my data I have all the values declared as not null and not sure why I am getting this error. Please help.
MyCode:
I am getting total results by doing a call to Db
var result = _retailerStatsRepository.GetAllRetailersForManufacturerCountryAndCategorySelectedDates(manufacturerRow.Id,
countryRow.Id,
categoryRow.Id,
cumLeads.StartDate,
cumLeads.EndDate);
Note:
I am trying to use result for my further queries using Linq
retailerWeeklyClickCount = result.Where(
i =>
i.Date >= localStart && i.Date <= localEnd && i.RetailerId == retailer.Id &&
i.ManufacturerId == manufacturerRow.Id
&& i.CountryId == countryRow.Id && i.CategoryId == categoryRow.Id).Sum(i => i.WidgetClicks);
I am getting error so I tries below
Edit
var retailerWeeklyClicks = result.Where(
i =>
i.Date >= localStart && i.Date <= localEnd && i.RetailerId == retailer.Id &&
i.ManufacturerId == manufacturerRow.Id
&& i.CountryId == countryRow.Id && i.CategoryId == categoryRow.Id);
if(retailerWeeklyClicks!=null)
{
retailerWeeklyClickCount = retailerWeeklyClicks.Sum(i => i.WidgetClicks);
}
But still getting same error and checked inn my DB and I have no data only for few days between my startdate and end date for the category I have selected.
StackTrace :
at System.Reflection.RuntimeMethodInfo.CheckConsistency(Object target) at System.Reflection.RuntimeMethodInfo.InvokeArgumentsCheck(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Reflection.RuntimePropertyInfo.GetValue(Object obj, BindingFlags invokeAttr, Binder binder, Object[] index, CultureInfo culture) at System.Reflection.RuntimePropertyInfo.GetValue(Object obj, Object[] index) at System.Data.Objects.ELinq.QueryParameterExpression.TryGetFieldOrPropertyValue(MemberExpression me, Object instance, Object& memberValue) at System.Data.Objects.ELinq.QueryParameterExpression.TryEvaluatePath(Expression expression, ConstantExpression& constantExpression) at System.Data.Objects.ELinq.QueryParameterExpression.EvaluateParameter(Object[] arguments) at System.Data.Objects.ELinq.ELinqQueryState.GetExecutionPlan(Nullable1 forMergeOption) at System.Data.Objects.ObjectQuery
1.GetResults(Nullable1 forMergeOption) at System.Data.Objects.ObjectQuery
1.System.Collections.Generic.IEnumerable.GetEnumerator() at System.Linq.Enumerable.Single[TSource](IEnumerable1 source) at System.Data.Objects.ELinq.ObjectQueryProvider.<GetElementFunction>b__3[TResult](IEnumerable
1 sequence) at System.Data.Objects.ELinq.ObjectQueryProvider.ExecuteSingle[TResult](IEnumerable1 query, Expression queryRoot) at System.Data.Objects.ELinq.ObjectQueryProvider.System.Linq.IQueryProvider.Execute[S](Expression expression) at System.Linq.Queryable.Sum[TSource](IQueryable
1 source, Expression1 selector) at reporting.e_tale.co.uk.Controllers.ReportsController.CumLeadsParameters(CumLeadsReport cumLeads) in d:\e-tale-core-development\trunk\reporting.e-tale.co.uk\Controllers\ReportsController.cs:line 492 at lambda_method(Closure , ControllerBase , Object[] ) at System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary
2 parameters) at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary2 parameters) at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass15.<InvokeActionMethodWithFilters>b__12() at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func
1 continuation)
As I am new to Linq , please help me if I am doing anything wrong.