DevTeam.QueryMappings 3.5.8

dotnet add package DevTeam.QueryMappings --version 3.5.8
NuGet\Install-Package DevTeam.QueryMappings -Version 3.5.8
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="DevTeam.QueryMappings" Version="3.5.8" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add DevTeam.QueryMappings --version 3.5.8
#r "nuget: DevTeam.QueryMappings, 3.5.8"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install DevTeam.QueryMappings as a Cake Addin
#addin nuget:?package=DevTeam.QueryMappings&version=3.5.8

// Install DevTeam.QueryMappings as a Cake Tool
#tool nuget:?package=DevTeam.QueryMappings&version=3.5.8

QueryMappings

Query mappings provide simple strongly typed interface optimized for Entity Framework and IQueryable.

TeamCity Build Status NuGet

Motivation

As we use Entity Framework and IQueryable interface for a tons of different projects, we needed some naturally adaptable mapping interface to IQueryable interface. This interface should support possibility to pass arguments for more complicated mapping cases. Also there are cases when we can't have Navigation Property between objects or when we want to write LINQ syntax for queries, so we needed possibility to inject EF Context inside of the mapping.

Features

  1. Simple and strongly typed mapping interface. Mappings API should be natural - we just map one object to another, we don't need 10 different methods just to do it:

    _mappingsList.Add<Address, AddressModel>(x => new AddressModel
    {
        Id = x.Id,
        BuildingNumber = x.BuildingNumber,
        City = x.City,
        State = x.State,
        Country = (Countries)x.Country,
        Street = x.Street,
        ZipCode = x.ZipCode
    });

  1. Oriented on Entity Framework. Best support of IQueryable and even injection of Entity Framework context inside of the mapping expression.

_mappingsList.Add<Building, BuildingStatisticsModel, BuildingArguments, IDbContext>(args =>
{
    return (query, context) => 
        from building in query
        join review in context.Set<Review>() on new { EntityId = building.Id, EntityTypeId = (int)EntityType.Building }
                                             equals new { EntityId = review.EntityId, EntityTypeId = review.EntityTypeId }
                                             into reviews
        let address = building.Address
        select new BuildingStatisticsModel
        {
            Id = building.Id,
            Address = address.BuildingNumber + ", " + address.Street + ", " + address.City,
            AppartmentsCount = building.Appartments.Count(),
            Size = building.Appartments.Sum(app => app.Size),
            ResidentsCount = building.Appartments.SelectMany(app => app.Residents).Where(r => r.Age > args.TargetResidentsAge).Count(),
            AverageBuildingRating = reviews.Average(r => r.Rating)
        };
});

  1. Possibility to pass and use arguments inside of the mapping

_mappingsList.Add<Appartment, AppartmentModel, AppartmentsArguments>(args =>
{
    return x => new AppartmentModel
    {
        Id = x.Id,
        Badrooms = x.Badrooms,
        Bathrooms = x.Bathrooms,
        Floor = x.Floor,
        IsLodge = x.IsLodge,
        Number = x.Number,
        Size = x.Size.ToString() + args.UnitOfMeasure
    };
});

  1. Strobgly typed interface. If types of your models have changed you will see compile-time errors.

  2. No any reflection is used in runtime. Only one place when reflection is used - start of application.

Documentation

You can find documentation in the wiki to this repository.

Support

If you found any bug, please submit bug in our [issue tracker] (https://github.com/DevTeamHub/QueryMappings/issues). If you can submit [pull request] with fix (https://github.com/DevTeamHub/QueryMappings/pulls) - even better! And we will be happy to hear different suggestions to improve this project.

Future

Main features in the near future is reusable mappings and object-to-object mappings. You can find roadmap to the project here.

How to start

Please reference to quick start in our wiki.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  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 is compatible.  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. 
.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 is compatible. 
.NET Framework net461 was computed.  net462 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETFramework 4.6.2

    • No dependencies.
  • .NETStandard 2.0

    • No dependencies.
  • .NETStandard 2.1

    • No dependencies.
  • net6.0

    • No dependencies.
  • net7.0

    • No dependencies.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on DevTeam.QueryMappings:

Package Downloads
DevTeam.GenericService

Package provides integration between Generic Repository and Query Mappings for Entity Framework

DevTeam.QueryMappings.AspNetCore

The package helps to integrate DevTeam.QueryMappings into ASP.NET Core project.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
3.5.8 355 8/3/2023
3.5.6 864 4/11/2023
3.5.5 140 4/11/2023
3.5.1 655 4/7/2023
3.5.0 492 4/7/2023
3.3.0 2,751 9/6/2021
3.2.0 349 9/6/2021
3.1.0 443 9/6/2021
3.0.0 685 9/4/2021
2.1.0 1,125 1/3/2020
2.0.1 994 4/16/2018
2.0.0 1,028 4/15/2018
2.0.0-rc 792 4/14/2018
1.0.4 1,073 12/2/2016
1.0.3 1,227 7/5/2016
1.0.2 1,223 7/5/2016
1.0.0 2,350 5/22/2016