CSESoftware.Repository
3.0.0-beta03
dotnet add package CSESoftware.Repository --version 3.0.0-beta03
NuGet\Install-Package CSESoftware.Repository -Version 3.0.0-beta03
<PackageReference Include="CSESoftware.Repository" Version="3.0.0-beta03" />
<PackageVersion Include="CSESoftware.Repository" Version="3.0.0-beta03" />
<PackageReference Include="CSESoftware.Repository" />
paket add CSESoftware.Repository --version 3.0.0-beta03
#r "nuget: CSESoftware.Repository, 3.0.0-beta03"
#:package CSESoftware.Repository@3.0.0-beta03
#addin nuget:?package=CSESoftware.Repository&version=3.0.0-beta03&prerelease
#tool nuget:?package=CSESoftware.Repository&version=3.0.0-beta03&prerelease
CSESoftware.Repository
A generic repository pattern.
Note: This defines the interfaces. For implimentations, please see CSESoftware.Repository.EntityFramework or CSESoftware.EntityFrameworkCore
Instructions for using the Query Builder
All below queries assume the following class structure:
public class User : BaseEntity<Guid>
{
public string Name { get; set; }
public string AddressOne { get; set; }
public string AddressTwo { get; set; }
public string City { get; set; }
public string State { get; set; }
public string Zip { get; set; }
public string Phone { get; set; }
public string SecondaryPhone { get; set; }
public string Initials { get; set; }
public Department Department { get; set; }
}
public class Department : BaseEntity<Guid>
{
public string Name { get; set; }
}
Basic query with a predicate:
public async Task Query()
{
var inActiveUsersQuery = new QueryBuilder<User>()
.Where(x => x.IsActive == false)
.Build();
var inActiveUsers = await repository.GetAllAsync(inActiveUsersQuery);
}
Query with a join to another entity:
public async Task Join()
{
var inActiveUsersWithDepartmentsQuery = new QueryBuilder<User>()
.Where(x => x.IsActive == false)
.Include(x => x.Department)
.Build();
var inActiveUsersWithDepartments = await _repository.GetAllAsync(inActiveUsersWithDepartmentsQuery);
}
Pagination with skip/take:
public async Task Paginate()
{
var paginateInActiveUsersQuery = new QueryBuilder<User>()
.Where(x => x.IsActive == false)
.Skip(5)
.Take(10)
.Build();
var paginatedInActiveUsers = await _repository.GetAllAsync(paginateInActiveUsersQuery);
}
Ordering query results:
public async Task Order()
{
var orderUsersQuery = new QueryBuilder<User>()
.OrderBy(x => x.Name)
.ThenByDescending(x => x.AddressOne)
.Build();
var orderedUsers = await _repository.GetAllAsync(orderUsersQuery);
}
Specifying columns to be returned:
public async Task SpecifyReturn()
{
var nameOfInactiveUsersQuery = new QueryBuilder<User>()
.Where(x => x.IsActive == false)
.Select(x => x.Name)
.Build();
var nameOfInactiveUsers = await _repository.GetAllWithSelectAsync(nameOfInactiveUsersQuery);
}
Queries can be saved through concrete classes and reused later:
public class UserQueries
{
public IQuery<User> GetAllInactiveUsers()
{
return new QueryBuilder<User>()
.Where(x => x.IsActive == false)
.Build();
}
public IQuery<User> GetAllInactiveUsersWithDepartment()
{
return new QueryBuilder<User>()
.Where(x => x.IsActive == false)
.Include(x => x.Department)
.Build();
}
}
CSE Software Inc. is a privately held company founded in 1990. CSE develops software, AR/VR, simulation, mobile, and web technology solutions. The company also offers live, 24x7, global help desk services in 110 languages. All CSE teams are U.S. based with experience in multiple industries, including government, military, healthcare, construction, agriculture, mining, and more. CSE Software is a certified women-owned small business. Visit us online at csesoftware.com.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. 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. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- CSESoftware.Core (>= 3.0.0-beta03)
NuGet packages (3)
Showing the top 3 NuGet packages that depend on CSESoftware.Repository:
| Package | Downloads |
|---|---|
|
CSESoftware.Repository.EntityFrameworkCore
The Entity Framework Core implementation of CSESoftware.Repository. |
|
|
CSESoftware.OData
Library to convert Open Data REST API queries into queries for CSESoftware.Repository. |
|
|
CSESoftware.Repository.EntityFramework
The Entity Framework implementation of CSESoftware.Repository. |
GitHub repositories
This package is not used by any popular GitHub repositories.