FluentImport 0.0.1-alpha
See the version list below for details.
dotnet add package FluentImport --version 0.0.1-alpha
NuGet\Install-Package FluentImport -Version 0.0.1-alpha
<PackageReference Include="FluentImport" Version="0.0.1-alpha" />
paket add FluentImport --version 0.0.1-alpha
#r "nuget: FluentImport, 0.0.1-alpha"
// Install FluentImport as a Cake Addin #addin nuget:?package=FluentImport&version=0.0.1-alpha&prerelease // Install FluentImport as a Cake Tool #tool nuget:?package=FluentImport&version=0.0.1-alpha&prerelease
FluentImport [Alpha]
This Nuget package let you simple import datasets from different sources and perfom actions on it.
Installation
Install-Package FluentImport
Usage
Importer with one source and one simple action
await FluentImport
.Create<ICollection<DutchIntensiveCare>>()
.Sources(config =>
{
config.Url("https://lcps.nu/wp-content/uploads/covid-19.csv", mapper =>
{
return mapper.FromCsv<ICollection<DutchIntensiveCare>, DutchIntensiveCare>(m =>
{
m.Map(e => e.Date).Name("Datum");
m.Map(e => e.BedsCovid).Name("IC_Bedden_COVID");
m.Map(e => e.BedsNonCovid).Name("IC_Bedden_Non_COVID");
});
});
})
.Actions(config => config.Custom(beds =>
{
foreach (var bed in beds)
{
Console.WriteLine($"{bed.Date} - Total beds occupied: {bed.BedsCovid + bed.BedsNonCovid}");
Console.WriteLine($"{bed.Date} - Covid: {bed.BedsCovid}, Non-Covid: {bed.BedsNonCovid}");
}
}))
.Build()
.Import()
.ConfigureAwait(false);
Documentation
With FluentImport you can use the create a importer using FluentImport.Create<T>()
as starting point, where generic T
is the source structure.
Sources
You can setup multiple sources where you want to import from. Most sources has a own mapper which is responsible for mapping it from the source structure into a structure you want to use during the importing.
Available sources
.Url(this IFluentImportSourceConfig<T> _, string url, Func<IFluentImportMapperConfig<T>, IFluentImportMapper<T>> mapper);
.Data(this IFluentImportSourceConfig<T> _, T data);
.Add(IFluentImportSource<T> source);
(creating custom source)
Available mappers
.FromJson(this IFluentImportMapperConfig<T> _, JsonSerializerOptions options);
.FromXml(this IFluentImportMapperConfig<T> _, Func<XDocument, T> mapper);
.FromCsv(this IFluentImportMapperConfig<T> _, Action<ClassMap<TElement>> mapping, Action<CsvConfiguration> csvConfiguration);
.Custom(this IFluentImportMapperConfig<T> _, Func<Stream, T> mapper);
.CustomAsync(this IFluentImportMapperConfig<T> _, Func<Stream, Task<T>> mapper);
Joining multiple sources into one source
When you have multiple sources defined, is faster to joins the results from the sources into one source.
.JoinSources(Func<ICollection<T>, T> joinFunc);
Actions
Once the data is retrieved from the source(s) is imported, you can perform actions on it.
Available actions
.Custom<T>(this IFluentImportActionConfig<T> config, Action<T> action);
.CustomAsync<T>(this IFluentImportActionConfig<T> config, Func<T, Task> action);
.Add(IFluentImportAction<T> source);
(creating custom action)
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
License
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 is compatible. 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. |
-
net5.0
- No dependencies.
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.4 | 352 | 4/21/2021 |
0.0.3-alpha | 224 | 4/21/2021 |
0.0.2-alpha | 217 | 4/19/2021 |
0.0.1-alpha | 217 | 4/18/2021 |