question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Question: Would it be possible to apply your `filter` / queryProcessing logic to standard `IEnumerable` / `IQueryable`

See original GitHub issue

SUMMARY

I really like your approach to filter / order / paginate data by a URI query string. Especially the filter aggregation with and, or and () is nice and very flexible.

I’m currently developing a small command line audio tagger and asked myself, if it would be possible to apply YOUR query processing to a generic IEnumerable or IQueryable?

I would love to see a library providing this part of your work for a more generic purpose…

Basically what I’m asking for is something like this:

# my command line tool recursiveley iterates over files in a directory and should be able to filter them
tone dump --sort="size" --page=1 --filter=equals(Artist,'AC/DC') /home/sandreas/music
// any class 
class MediaFile {
    public long FileSize;
    public string Artist;
    public IEnumerable<Picture> Covers;
    //... 
}

// a generic enumberable
IEnumerable<MediaFile> mediaFiles = FileWalker.FindMediaFiles();

// your query processing logic applied to this generic IQueryable?!
var queryProcessor = new QueryProcessor(options.Sort, options.Page, options.Filter);
var filteredMediaFiles = queryProcessor.Apply(mediaFiles);

foreach(var mediaFile in filteredMediaFiles) {
    Console.WriteLine(mediaFile.Artist);
}

What do you think? Would that be possible / worth the effort?

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
bkoelmancommented, Jul 2, 2022

I’ve done some experiments and concluded that extracting the querying logic from JADNC is not feasible at this time. This is due to dependencies on the resource graph, EF Core, HttpContext, and various others. However the good news is: you can already reuse JADNC today for what you’re trying to accomplish. Two approaches:

  1. Use a light-weight database (such as Sqlite) and split your command-line tool into two modes: one to scan the filesystem and build/refresh the database, the other to query it. This enables lightning-fast queries over multiple resource types. For example: give me all tracks from a specific artist, give me all tracks of this genre, etc. #1144 shows how to accomplish that. This is the easiest solution.
  2. Use the approach at #1165, which does not require a database. While scanning the file system, you’d build an in-memory object model of resources and their relationships.

In either case, based on command-line switches you need to construct a query string (matching what JADNC accepts when running as an ASP.NET Web API).

0reactions
bkoelmancommented, Jul 2, 2022

Glad to help. I wish you good luck with your project.

Read more comments on GitHub >

github_iconTop Results From Across the Web

IEnumerable vs IQueryable for Business Logic or DAL ...
If I need additional filtering, then either: I'll add that to the existing API via parameters, and do the filtering inside my data...
Read more >
IQueryable vs. IEnumerable in .NET | by Mohamed Abdeen
IEnumerable interface is useful when your collection is loaded using LINQ or Entity framework and you want to apply a filter on the...
Read more >
IEnumerable VS IQueryable
Both have its own importance to query data and data manipulation. Let's see both the features and take advantage of both the features...
Read more >
IEnumerable Vs IQueryable In LINQ
In this article I will demonstrate how to write code via IEnumerable and IQueryable and what the differences are between them.
Read more >
Standard Query Operators Overview (C#)
The LINQ standard query operators provide query capabilities including filtering, projection, aggregation, and sorting in C#.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found