{"id":21277666,"url":"https://github.com/bytedecoder/queryology","last_synced_at":"2025-07-11T08:31:55.402Z","repository":{"id":37881864,"uuid":"276530036","full_name":"ByteDecoder/Queryology","owner":"ByteDecoder","description":"Minimalist query engine executor used with Entity Framework Core + LINQ for quick experiments","archived":false,"fork":false,"pushed_at":"2024-11-15T20:57:26.000Z","size":351,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-11-15T21:29:29.389Z","etag":null,"topics":["console-application","csharp","csharp-library","dotnet-core","entity-framework-core","linq"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ByteDecoder.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-07-02T02:33:22.000Z","updated_at":"2024-11-15T20:56:25.000Z","dependencies_parsed_at":"2023-10-10T20:33:08.273Z","dependency_job_id":"99ac8fb6-be05-4ed6-b46d-913936a9433a","html_url":"https://github.com/ByteDecoder/Queryology","commit_stats":null,"previous_names":[],"tags_count":22,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ByteDecoder%2FQueryology","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ByteDecoder%2FQueryology/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ByteDecoder%2FQueryology/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ByteDecoder%2FQueryology/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ByteDecoder","download_url":"https://codeload.github.com/ByteDecoder/Queryology/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225708290,"owners_count":17511635,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["console-application","csharp","csharp-library","dotnet-core","entity-framework-core","linq"],"created_at":"2024-11-21T10:06:47.205Z","updated_at":"2024-11-21T10:06:48.223Z","avatar_url":"https://github.com/ByteDecoder.png","language":"C#","readme":"# Queryology\n\n![CI](https://github.com/ByteDecoder/Queryology/workflows/CI/badge.svg)\n[![CodeQL](https://github.com/ByteDecoder/Queryology/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/ByteDecoder/Queryology/actions/workflows/codeql-analysis.yml)\n[![Maintainability](https://api.codeclimate.com/v1/badges/5636af5394315faa7bd8/maintainability)](https://codeclimate.com/github/ByteDecoder/Queryology/maintainability)\n[![Test Coverage](https://api.codeclimate.com/v1/badges/5636af5394315faa7bd8/test_coverage)](https://codeclimate.com/github/ByteDecoder/Queryology/test_coverage)\n![License](https://img.shields.io/badge/license-MIT-green)\n\nYou can find the documentation for previous versions \u003c 1.0.0 here [documentation until v0.4.3 here](DOCUMENTATION_UNTIL_0.4.3.md)\n\nMinimalist query engine executor used with Entity Framework Core + LINQ for quick experiments\n\nTargeted to .Net 8\n\n## Installation\n\nInstall the [Queryology NuGet Package](https://www.nuget.org/packages/ByteDecoder.Queryology).\n\n### Package Manager Console\n\n```porwershell\nInstall-Package ByteDecoder.Queryology\nInstall-Package ByteDecoder.Queryology.Providers.ObjectDumper\n```\n\n### .NET Core CLI\n\n```bash\ndotnet add package ByteDecoder.Queryology\ndotnet add package ByteDecoder.Queryology.Providers.ObjectDumper\n```\n\n## Examples and usage\n\nIf you are exploring a query or learning _Entity Framework core_, and want to analyze, understand, and doing some experiments, but you do not want to spend a lot of time doing boilerplate infrastructure. Enter the **Queryology Engine**.\n\nBy using it, allow you to stay focus reviewing and writing your queries, executing them, and you can disable them for not execution in runtime with the minimal code changes.\n\nThe basic theory that you need:\n\n- **Queryology** NuGet package installed and _Object Dumper_ provider\n- Your _EF Core DbContext class_, or if you want to use only _LINQ to Objects_, **Queryology** provides a default _NullDbContext_ to avoid setting one by yourself\n- Have a query class per each one of your experiments\n- Inherit and implement _QueryBase\\\u003cT\\\u003e_ where **T** is the type of your _EF Core DbContext class_\n- **QueryBase\\\u003cT\\\u003e** Uses a delegate to display the output. An **ObjectDumper** provider from Microsoft is included as base for exploring your Linq results\n- Don't forget to add a _logger_ in your _EF Core DbContext class_ to analyze the _SQL output_\n- Just call an instance of **QueryologyEngine** with your _EF Core DbContext class_ and, it will find for you all your query classes that inherit from **QueryBase\\\u003cT\\\u003e** and it will execute them\n- Enjoy\n\n**QueryBase\\\u003cT\\\u003e** Provides you:\n\n- _DataContext property_ which holds the reference to the provided _EF Core DbContext class_\n- _DisplayData method_ to write in the console the structure of your query result using the **Data** property\n- _Data property_ defined as _object_ since you can project _anonymous types_ with LINQ\n- _Executable property_ that is overridable to set to **false** if you do not want this rule to be executed by _QueryologyEngine_\n\nMinimalist EF Core DbContext example code:\n\n```csharp\n// Create your EF Core DbContext class\npublic class MyDbCoreContext : DbContext { ... }\n\n// Write your query class(es) and inherit from QueryBase\u003cT\u003e where T\n// is your EF Core DbContext class\npublic class MyQuery : QueryBase\u003cMyDbCoreContext\u003e\n{\n    public MyQuery(MyDbCoreContext dbContext, DisplayObjectData objectDisplayer)\n      : base(dataContext, objectDisplayer) { }\n\n    public override void Execute()\n    {\n        Data = DataContext.Books\n          .Include(b =\u003e b.AuthorsLink)\n            .ThenInclude(a =\u003e a.Author)\n\n          .Include(b =\u003e b.Reviews)\n          .Include(b =\u003e b.Promotion)\n          .First();\n\n        DisplayData($\"{typeof(MyQuery)} query results:\", 3);\n    }\n}\n\n// In your .Net Core application, instantiate the engine and execute it!\nusing ByteDecoder.Queryology;\nusing ByteDecoder.Queryology.Providers.ObjectDumper;\n\nclass Program\n{\n    static void Main(string[] args)\n    {\n        using var dbContext = new MyDbCoreContext();\n        var totalQueries = new QueryologyEngineBuilder\u003cEfCoreContext\u003e()\n            .Configure(options =\u003e options.DataContextProvider = dbContext)\n            .AddObjectDumper()\n            .Build()\n            .Execute();\n\n\n        Console.WriteLine($\"\\n🦄🦄 Total Queries allowed to be executed: {totalQueries}\");\n        Console.WriteLine(\"🐵🐵 Press Enter to continue... 🐵🐵\");\n        Console.ReadLine();\n    }\n}\n```\n\nMinimalist EF Core only with LINQ to Objects example code:\n\n```csharp\n// Write your query class(es) and inherit from QueryBase\u003cT\u003e and use NullDbContext\n// as your type T\npublic class LinqToObjectsQuery : QueryBase\u003cNullDbContext\u003e\n{\n    public LinqToObjectsQuery(NullDbContext dbContext, DisplayObjectData objectDisplayer)\n      : base(dataContext, objectDisplayer) { }\n\n    public override void Execute()\n    {\n        Console.WriteLine(\"Some LINQ to Objects code here\");\n    }\n}\n\n// In your .Net Core application, instantiate the engine and execute it!\nusing ByteDecoder.Queryology;\nusing ByteDecoder.Queryology.Providers.ObjectDumper;\n\nclass Program\n{\n    static void Main(string[] args)\n    {\n        using var nullDbContext = new NullDbContext();\n        totalQueries = new QueryologyEngineBuilder\u003cNullDbContext\u003e()\n          .Configure(options =\u003e options.DataContextProvider = nullDbContext)\n          .AddObjectDumper()\n          .Build()\n          .Execute();\n\n\n        Console.WriteLine($\"\\n🦄🦄 Total Queries allowed to be executed: {totalQueries}\");\n        Console.WriteLine(\"🐵🐵 Press Enter to continue... 🐵🐵\");\n        Console.ReadLine();\n    }\n}\n```\n\nMark a _Query class_ to be ignored and not to be executed at runtime:\n\n```csharp\n// Just override the Executable property; and set it to false.\npublic class NeverAgainQuery : QueryBase\u003cMyDbCoreContext\u003e\n{\n    public NeverAgainQuery(EfCoreContext dbContext, DisplayObjectData objectDisplayer)\n      : base(dataContext, objectDisplayer) { }\n\n    public override bool Executable =\u003e false;\n\n    public override void Execute()\n    {\n        Console.WriteLine(\"Never again.. I will never get executwed by QueryologyEngine =(\");\n        throw new NotImplementedException();\n    }\n}\n```\n\nIgnore excluded queries and execute all queries under type **T**\n\n```csharp\n// Changing the default value of *IgnoreExcludedQueries* resets to its true default value\n// after the engine completes all the query processing\nusing var nullDbContext = new NullDbContext();\nvar queryologyEngine = new QueryologyEngineBuilder\u003cNullDbContext\u003e()\n  .Configure(options =\u003e options.DataContextProvider = nullDbContext)\n  .AddObjectDumper()\n  .Build();\n\nvar totalQueries = queryologyEngine\n  .IgnoreExcludedQueries(false)\n  .Execute();\n```\n\nThat is all, you can continue adding more queries and do not bother about the infrastructure\n\n## Running Example .Net Core Console App\n\nFirst create the example database and apply the migrations with:\n\n```bash\ncd ./src\ndotnet ef database update -p ./Queryology.Example\n```\n\nThen run the example console project:\n\n```bash\ncd Queryology.Example/\ndotnet run\n```\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at \u003chttps://github.com/ByteDecoder/Queryology\u003e.\n\nCopyright (c) 2020 [Rodrigo Reyes](https://twitter.com/bytedecoder) released under the MIT license\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbytedecoder%2Fqueryology","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbytedecoder%2Fqueryology","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbytedecoder%2Fqueryology/lists"}