Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

500 server internal error when sorting on column whose value comes from a function #182

Open
michael-ciavattone opened this issue Jan 29, 2018 · 1 comment
Labels

Comments

@michael-ciavattone
Copy link

michael-ciavattone commented Jan 29, 2018

When sorting by Title or summary or Ev01Value it works fine, but when i try to sort on any of the EVLabels that the value comes from a function i get the 500 error. If we sort by another column, it will get the values from the function and display them without any issue. It only happens when we try to sort on a column whose value comes from a function.

[Paginated]
[AllowsQuery]
 [ReturnsResource(typeof(IdeaResource))]
 [HttpGet]
 [SecureAccess("idealist-view")]
 public IQueryable Get(string query = "", string type = "")
 {         
  var resault = ideaQuery.Select(idea =>
    new IdeaModel
     {
         SubmitterId = idea.SubmitterID,
         Summary = idea.Summary,
         Title = idea.Title,
         Ev01Label = this.getPointer(evaluationFieldOptionsJson, 1, idea.Ev01Label, idea.ID),
         Ev02Label = this.getPointer(evaluationFieldOptionsJson, 2, idea.Ev02Label, idea.ID),
         Ev03Label = this.getPointer(evaluationFieldOptionsJson, 3, idea.Ev03Label, idea.ID),
         Ev04Label = this.getPointer(evaluationFieldOptionsJson, 4, idea.Ev04Label, idea.ID),
         Ev05Label = this.getPointer(evaluationFieldOptionsJson, 5, idea.Ev05Label, idea.ID),
         Ev06Label = this.getPointer(evaluationFieldOptionsJson, 6, idea.Ev06Label, idea.ID),
         Ev07Label = this.getPointer(evaluationFieldOptionsJson, 7, idea.Ev07Label, idea.ID),
         Ev08Label = this.getPointer(evaluationFieldOptionsJson, 8, idea.Ev08Label, idea.ID),
         Ev09Label = this.getPointer(evaluationFieldOptionsJson, 9, idea.Ev09Label, idea.ID),
         Ev010Label = this.getPointer(evaluationFieldOptionsJson, 10, idea.Ev010Label, idea.ID),
         Ev01Value = idea.Ev01Value,
         Ev02Value = idea.Ev02Value,
         Ev03Value = idea.Ev03Value,
         Ev04Value = idea.Ev04Value,
         Ev05Value = idea.Ev05Value,
         Ev06Value = idea.Ev06Value,
         Ev07Value = idea.Ev07Value,
         Ev08Value = idea.Ev08Value,
         Ev09Value = idea.Ev09Value,
         Ev010Value = idea.Ev010Value
    });
     return resault;
 }

private string getPointer(string options, int index, string EvLabel, int ideaId)
{
    var optionList = JsonConvert.DeserializeObject<List>(options, JsonHelper.GetDefaultSettings());
            
    var option = optionList.FirstOrDefault(p => p.Index == index);
    if (option != null)
    {            
      using (IRepositoryUnitOfWorkRead work = this.Tenant.Repository.GetUnitOfWorkRead())
      {
         return EvaluationDatabaseHelper.GetEvaluationFieldResponse(index, ideaId, work);
      }
    }
     else
       return EvLabel;
}
          

@joukevandermaas
Copy link
Owner

There's nothing in Saule that should care about where the data came from. Perhaps these methods are doing some kind of lazy evaluation that breaks with the queries Saule is generating? Saule does the equivalent of the following:

result = result.OrderBy(idea => idea.Ev01Label);

Perhaps you can try run that and see if that also fails?

As a second idea, is there any reason you cannot return the generic version IQueryable<T>? If it's possible please try that as well, because it could be the case that Saule breaks on regular IQueryable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants