PowerAppsWebApiUtils 0.0.0.3

There is a newer version of this package available.
See the version list below for details.
dotnet add package PowerAppsWebApiUtils --version 0.0.0.3
NuGet\Install-Package PowerAppsWebApiUtils -Version 0.0.0.3
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="PowerAppsWebApiUtils" Version="0.0.0.3" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add PowerAppsWebApiUtils --version 0.0.0.3
#r "nuget: PowerAppsWebApiUtils, 0.0.0.3"
#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 PowerAppsWebApiUtils as a Cake Addin
#addin nuget:?package=PowerAppsWebApiUtils&version=0.0.0.3

// Install PowerAppsWebApiUtils as a Cake Tool
#tool nuget:?package=PowerAppsWebApiUtils&version=0.0.0.3

This is an API to work with PowerApps and Dynamics 365 Web API

Design goals include

Early bound classes for web api Simple Linq provider for web api.

Targets .netcore 2.0 and (soon) .net framework 4.7 Integrate well with Azure Active Directory

Feedback and contributions welcome...

Examples of supported Linq queries:

To get the service context: var config = new PowerAppsAuthenticationSettings
{ ClientId = configuration["clientId"], ClientSecret = configuration["secret"], DirectoryId = configuration["directory"], ApiUrl = configuration["powerappsApiUrl"], ResourceUrl = configuration["powerappsUrl"],
};

serviceProvider = new ServiceCollection() .AddPowerAppsWebApiConfiguration(config) .BuildServiceProvider();

var context = serviceProvider.GetService<WebApiContext>();

To create a new query:

To create an entity: /// await context.Create(new CustomerAddress{ ParentId = new Account(Guid.NewGuid()).ToNavigationProperty() }); /// await context.Create( new Contact { FirstName = "First Name", LastName="LastName", OwnerId = new NavigationProperty { LogicalCollectionName = "systemusers", EntityLogicalName = "systemuser", Id = ownerid },
ParentCustomerId = new Account(parentcustomerid).ToNavigationProperty() });

To delete an entity: contact = new Contact(Guid.NewGuid()); await context.Delete(contact);

To select, filter and order:

context.CreateQuery<Account>().Where(p ⇒ p.Address1_Country == "Canada").Select(p ⇒ new Account(p.Id) { Name = p.Name}).OrderBy(p ⇒ p.Name).ToList(); context.CreateQuery<Account>().ToList(); context.CreateQuery<Account>().FirstOrDefault(); context.CreateQuery<Account>().Where(p ⇒ p.Name == "Test").ToList(); context.CreateQuery<Account>().Where(p ⇒ p.Name == "Test").FirstOrDefault(); context.CreateQuery<Account>().Where(p ⇒ p.StateCode == account_statecode.Active).ToList(); context.CreateQuery<Account>().Where(p ⇒ p.StateCode == account_statecode.Active).FirstOrDefault(); context.CreateQuery<Account>().Where(p ⇒ p.Name == "Test").Where(p ⇒ p.StateCode == account_statecode.Active); context.CreateQuery<Account>().Where(p ⇒ p.Name == "Toto" || p.Name == "Tata").Where(p ⇒ p.StateCode == account_statecode.Active).ToList(); context.CreateQuery<Account>().Where(p ⇒ p.Name == "Toto" || p.Name == "Tata").Where(p ⇒ p.StateCode == account_statecode.Active).FirstOrDefault();

context.CreateQuery<CustomerAddress>().Where(p ⇒ p.ParentId == new Account(Guid.NewGuid()).ToNavigationProperty()).Where(p ⇒ p.ShippingMethodCode == customeraddress_shippingmethodcode.Airborne && p.Country == "Canada").ToList(); context.CreateQuery<CustomerAddress>().Where(p ⇒ p.ParentId == new Account(Guid.NewGuid()).ToNavigationProperty()).Where(p ⇒ p.ShippingMethodCode == customeraddress_shippingmethodcode.Airborne && p.Country == "Canada").FirstOrDefault(); context.CreateQuery<CustomerAddress>().Where(p ⇒ p.ParentId == new Account(Guid.NewGuid()).ToNavigationProperty()).Select(p ⇒ new { Id = p.Id, OwnerId = p.OwnerId }).ToList(); context.CreateQuery<CustomerAddress>().Where(p ⇒ p.ParentId == new Account(Guid.NewGuid()).ToNavigationProperty()).Select(p ⇒ new { Id = p.Id, OwnerId = p.OwnerId }).FirstOrDefault();

context.CreateQuery<Account>().OrderByDescending(p ⇒ p.Name).ToList(); context.CreateQuery<Account>().OrderByDescending(p ⇒ new {p.Address1_City, p.Name} ).ToList(); context.CreateQuery<Account>().Where(p ⇒ p.StateCode == account_statecode.Active).OrderBy(p ⇒ p.Name).ToList(); context.CreateQuery<Account>().Where(p ⇒ p.StateCode == account_statecode.Active).OrderByDescending(p ⇒ p.Name).ToList(); context.CreateQuery<Account>().Where(p ⇒ p.StateCode == account_statecode.Active).OrderBy(p ⇒ new {p.Address1_City, p.Name}).ToList(); context.CreateQuery<Account>().Where(p ⇒ p.StateCode == account_statecode.Active).OrderByDescending(p ⇒ new {p.Address1_City, p.Name}).ToList(); context.CreateQuery<Account>().Where(p ⇒ p.StateCode == account_statecode.Active).Select(p ⇒ new { Name = p.Name, Id = p.Id, CreatedBy = p.CreatedBy }).OrderBy(p ⇒ p.Name).ToList(); context.CreateQuery<Account>().Where(p ⇒ p.StateCode == account_statecode.Active).Select(p ⇒ new { Name = p.Name, Id = p.Id, CreatedBy = p.CreatedBy }).OrderByDescending(p ⇒ p.Name).ToList(); context.CreateQuery<Account>().Where(p ⇒ p.StateCode == account_statecode.Active).OrderByDescending(p ⇒ p.Name).Select(p ⇒ new { Name = p.Name, Id = p.Id, CreatedBy = p.CreatedBy }).ToList(); context.CreateQuery<Account>().Where(p ⇒ p.StateCode == account_statecode.Active).Select(p ⇒ new Account{ Id = p.Id, CustomerTypeCode = p.CustomerTypeCode }).OrderByDescending(p ⇒ p.Name).ToList(); context.CreateQuery<Account>().Where(p ⇒ p.Name == "John").Where(p ⇒ p.StateCode == account_statecode.Active).OrderByDescending(p ⇒ p.Name).Select(p ⇒ new Account{ Id = p.Id, CustomerTypeCode = p.CustomerTypeCode }).ToList(); context.CreateQuery<Account>().Where(p ⇒ p.Name == "John" || p.Name == "Doe").Where(p ⇒ p.StateCode == account_statecode.Active).OrderByDescending(p ⇒ p.Name).Select(p ⇒ new { Id = p.Id, CustomerTypeCode = p.CustomerTypeCode, ExchangeRate = p.ExchangeRate }).ToList(); context.CreateQuery<Account>().Where(p ⇒ p.StateCode == account_statecode.Active).Select(p ⇒ new { Id = p.Id, CreatedBy = p.CreatedBy }).ToList();

================================================================= You can still override the webapi request using the following method for operation not supported by webapi or use the async/await pattern:

var repository = serviceProvider.GetRequiredService<GenericRepository<Contact>>(); var querystring = $"{config.ApiUrl}{Contact.CollectionName}?$select=firstname,lastname,_parentcustomerid_value,address1_city&$filter=address1_city eq 'Redmond'&$orderby=lastname"; var contacts = await repository.RetrieveMultiple(querystring);

Product 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. 
.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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
0.0.0.10 701 1/22/2020
0.0.0.9 448 1/19/2020
0.0.0.8 563 1/15/2020
0.0.0.7 459 1/14/2020
0.0.0.6 509 8/13/2019
0.0.0.5 475 8/10/2019
0.0.0.4 479 8/10/2019
0.0.0.3 469 7/28/2019
0.0.0.2 474 7/15/2019

0.0.0.3 OrderBy / OrderByDescending support - Readme.md having few examples
   0.0.0.2 Include missing file PowerAppsWebApiUtils.Console.runtimeconfig.json
   0.0.0.1 Initial release. .net core app to generate early bound classes. Api exposes in .netstandard 2.0 supportin all CRUD operations and limited Linq support (ToList and FirstOrDefault)