Replies: 6 comments 1 reply
-
That could work. You'll always be executing Not sure if some options are common to the apply clause and other clauses we're using. I would inspect the tests to see the options we're using. I suspect you're looking for these: public ODataOptions EnableQueryFeatures(int? maxTopValue = null)
{
QuerySettings.EnableExpand = true;
QuerySettings.EnableSelect = true;
QuerySettings.EnableFilter = true;
QuerySettings.EnableOrderBy = true;
QuerySettings.EnableCount = true;
QuerySettings.EnableSkipToken = true;
SetMaxTop(maxTopValue);
return this;
} The tests should also be helpful for validating your custom attribute. |
Beta Was this translation helpful? Give feedback.
-
I think the existing text reflects a known issue with Tests are here, here and here. Ok to PR the ReadMe to reflect How To Combine Use Enable Query with this library in place of the Do Not Use section, add tests for the how to etc. |
Beta Was this translation helpful? Give feedback.
-
That sounds good! I've looked at those tests and with those tests I should be able to test this, but because of a couple of travel days I have (and currently a lack of understanding how to execute the unit tests in Web.Tests). The only consideration I had yesterday was that the fields used for the
But since I'm currently not able to tests this, I'm not sure whether this could works. However, is there anything I further can do on this? |
Beta Was this translation helpful? Give feedback.
-
To run the tests just start the web projects (
This is an open source project - there isn't a schedule :) |
Beta Was this translation helpful? Give feedback.
-
For example the model I would expect, based the column- and table mappings, a query on the database a kind of similar to this:
But the Thanks for helping me out with getting those WHAT?! No schedule?! No, just joking! Thanks for the understanding! I'm always on a schedule, but that's just me being impatient 😉 |
Beta Was this translation helpful? Give feedback.
-
Your mapping configuration should take care of the names e.g. grouping by Expression<Func<IQueryable<StudentModel>, IQueryable<object>>> ex = q => q.GroupBy(a => a.FullName).Select(s => new { s.Key, Count = s.Count() });
public class StudentModel
{
public string LastName { get; set; }
public string FirstName { get; set; }
public string FullName { get; set; }
}
public class Student
{
public string LastName { get; set; }
public string FirstName { get; set; }
} SELECT ([s].[FirstName] + N' ') + [s].[LastName] AS [Key], COUNT(*) AS [Count]
FROM [Student] AS [s]
GROUP BY ([s].[FirstName] + N' ') + [s].[LastName] |
Beta Was this translation helpful? Give feedback.
-
Hi,
In the readme is clearly stated that the EnableQueryAttribute should not be used because some query options are applied twice. Is it an option to exclude all query options in the EnableQueryAttribute that are already applied by this Automapper.Extensions.OData? If so, which query options should be ignored? The question would be; which query options are applied in the Automapper.Extensions.OData.
An example of this can be found here: https://learn.microsoft.com/en-us/odata/webapi/ignore-query-option. In this example a custom EnableQueryAttribute is created with default excluding some query options.
If this would be option then the problems with the "$apply" can be solved (at least for me) because then in the OData middleware the '$apply' and, as mentioned, in the readme the applied query options would not be applied twice.
Beta Was this translation helpful? Give feedback.
All reactions