TBARPT.Library
1.0.0
See the version list below for details.
dotnet add package TBARPT.Library --version 1.0.0
NuGet\Install-Package TBARPT.Library -Version 1.0.0
<PackageReference Include="TBARPT.Library" Version="1.0.0" />
<PackageVersion Include="TBARPT.Library" Version="1.0.0" />
<PackageReference Include="TBARPT.Library" />
paket add TBARPT.Library --version 1.0.0
#r "nuget: TBARPT.Library, 1.0.0"
#:package TBARPT.Library@1.0.0
#addin nuget:?package=TBARPT.Library&version=1.0.0
#tool nuget:?package=TBARPT.Library&version=1.0.0
Introduction
The purpose of this library is to enable Dynamic LINQ string construction and execution, as well as dynamically creating and executing queries using expression trees. This is intended to support specific applications local to our environment, though it may be useful to others. Helpers are also available for retrieving lists of properties, their types, and display names from a given type. Using ReflectionIgnore attribute will prevent a class from returing results, or individual properties from being included in the list of properties.
Getting Started
- Add this package as well as Dynamic LINQ
- Example usage:
using System.Reflection;
using TBARPT.Library;
using TBARPT.Library.Models;
using TBARPT.Repository.Repositories;
namespace TBARPT.Library.Example {
public class Example {
private readonly IReportRepository reportRepository;
public Example(IReportRepository reportRepository) {
this.reportRepository = reportRepository;
}
//when type is not known until runtime.
public QueryResult GetReport(QueryRequest queryRequest, string typeName) {
//use reflection to look up report source type
Type type = Type.GetType("namespace.of.type." + typeName + ", assemblyName")
?? throw new ArgumentException($"Type could not be resolved: {typeName}");
//use reflection to find queryable method
var queryMethod = reportRepository.GetType().GetMethod(typeName, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static)
?? throw new ArgumentException($"Invalid Report Source: {typeName}");
IQueryable<dynamic> baseQuery = (IQueryable<dynamic>?)queryMethod.Invoke(reportRepository, null)
?? throw new ArgumentException("Base query could not be resolved dynamically.");
var reportBuilder = Activator.CreateInstance(typeof(DynamicLINQReportBuilder<>).MakeGenericType(type))
?? throw new MissingMethodException("Could not create instance of DynamicLINQReportBuilder");
MethodInfo executeQuery = reportBuilder.GetType().GetMethod("GetReport")
?? throw new ArgumentException("GetReport method not found");
QueryResult result = (QueryResult?)executeQuery.Invoke(reportBuilder, [baseQuery, queryRequest])
?? throw new Exception("Execution of query returned null.");
return result;
}
//when type is known at compile time
public static QueryResult GetReport<T>(QueryRequest queryRequest, IQueryable<T> baseQuery) {
var reportBuilder = new DynamicLINQReportBuilder<T>();
QueryResult result = reportBuilder.GetReport((IQueryable<dynamic>)baseQuery, queryRequest);
return result;
}
}
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- System.Linq.Dynamic.Core (>= 1.6.0.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last Updated | |
---|---|---|---|
1.3.6 | 289 | 9/16/2025 | |
1.3.5 | 120 | 9/5/2025 | |
1.3.4 | 168 | 9/4/2025 | |
1.3.3.1-beta | 253 | 9/4/2025 | |
1.3.3 | 156 | 9/4/2025 | |
1.3.3-beta | 261 | 9/3/2025 | |
1.3.2 | 109 | 8/22/2025 | |
1.3.1 | 154 | 8/20/2025 | |
1.3.0 | 158 | 8/13/2025 | |
1.2.1-beta | 153 | 8/13/2025 | |
1.2.0-beta | 158 | 8/11/2025 | |
1.1.3 | 347 | 6/10/2025 | |
1.1.1 | 139 | 4/5/2025 | |
1.1.0 | 200 | 4/1/2025 | |
1.0.4 | 489 | 3/25/2025 | |
1.0.3 | 156 | 3/17/2025 | |
1.0.2 | 203 | 3/11/2025 | |
1.0.1 | 224 | 3/7/2025 | |
1.0.0 | 231 | 3/7/2025 |
Initial release.