PowerAppsWebApiUtils 0.0.0.5
See the version list below for details.
dotnet add package PowerAppsWebApiUtils --version 0.0.0.5
NuGet\Install-Package PowerAppsWebApiUtils -Version 0.0.0.5
<PackageReference Include="PowerAppsWebApiUtils" Version="0.0.0.5" />
paket add PowerAppsWebApiUtils --version 0.0.0.5
#r "nuget: PowerAppsWebApiUtils, 0.0.0.5"
// Install PowerAppsWebApiUtils as a Cake Addin #addin nuget:?package=PowerAppsWebApiUtils&version=0.0.0.5 // Install PowerAppsWebApiUtils as a Cake Tool #tool nuget:?package=PowerAppsWebApiUtils&version=0.0.0.5
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 .net framework 4.7 Integrate well with Azure Active Directory
Feedback and contributions welcome...
How tos:
Setup an application user for PowerAppsWebApiUtils: https://www.linkedin.com/pulse/how-setup-application-user-powerappswebapiutils-philippe-dufag Generate early bound classes and setup a project to use PowerAppsWebApiUtils: https://www.linkedin.com/pulse/powerappswebapiutils-howto-philippe-dufag
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 | 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. |
.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. |
-
- Microsoft.Extensions.Http (>= 2.2.0)
- Microsoft.IdentityModel.Clients.ActiveDirectory (>= 5.0.5)
- Newtonsoft.Json (>= 11.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.
0.0.0.5 Add missing nuget assemblies in "earlybound" folder.
Change PowerAppsWebApiUtils.Console to tools folder.
From docs.microsoft.com, "The tools folder is added to the PATH environment variable for the Package Manager Console only"
0.0.0.4 Standard OData string query functions support (BeginsWith, EndsWith, Contains)
Azure Functions have changed their dependency on Newtonsoft [Newtonsoft.Json (>= 11.0.2)], so integration with Azure Functions will be simplier now Microsoft.NET.Sdk.Functions/1.0.30-beta1
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)