![]() |
VOOZH | about |
dotnet add package MeshWeaver.Data --version 2.5.0
NuGet\Install-Package MeshWeaver.Data -Version 2.5.0
<PackageReference Include="MeshWeaver.Data" Version="2.5.0" />
<PackageVersion Include="MeshWeaver.Data" Version="2.5.0" />Directory.Packages.props
<PackageReference Include="MeshWeaver.Data" />Project file
paket add MeshWeaver.Data --version 2.5.0
#r "nuget: MeshWeaver.Data, 2.5.0"
#:package MeshWeaver.Data@2.5.0
#addin nuget:?package=MeshWeaver.Data&version=2.5.0Install as a Cake Addin
#tool nuget:?package=MeshWeaver.Data&version=2.5.0Install as a Cake Tool
MeshWeaver.Data provides data access and persistence capabilities for the MeshWeaver ecosystem. This library handles database interactions, data models, query operations, and data serialization to support the application's data management needs.
The MeshWeaver data system uses extension methods on MessageHubConfiguration to register data sources. Examples from the Northwind module show the configuration pattern:
public static MessageHubConfiguration AddNorthwindCustomers(
this MessageHubConfiguration configuration
)
{
return configuration
.AddImport()
.AddData(data =>
data.FromEmbeddedResource(
new EmbeddedResource(MyAssembly, "Files.customers.csv"),
config => config.WithType<Customer>()
)
);
}
// Client code using these extension methods
services.AddMeshWeaverHub(hub => hub
.AddNorthwindCustomers()
);
MeshWeaver.Data works with plain C# records and classes. Properties can be decorated with data annotations:
// From DataPluginTest.cs
public record MyData(string Id, [property:Required]string Text)
{
public static MyData[] InitialData = [new("1", "A"), new("2", "B")];
}
MeshWeaver.Data uses a reactive programming model with observables for data access and change tracking:
// From DataPluginTest.cs - CheckUsagesFromWorkspaceVariable test
var clientWorkspace = GetClient().GetWorkspace();
// Subscribe to data changes using an observable
var data = await clientWorkspace
.GetObservable<MyData>()
.Timeout(10.Seconds())
.FirstOrDefaultAsync();
data.Should().NotBeNull();
Common data operations through the workspace:
// From DataPluginTest.cs - Update test
// Get workspace and retrieve initial data
var clientWorkspace = client.GetWorkspace();
var data = (
await clientWorkspace
.GetObservable<MyData>()
.Timeout(10.Seconds())
.FirstOrDefaultAsync()
)
.OrderBy(a => a.Id)
.ToArray();
// Perform update with multiple items
var updateItems = new object[] { new MyData("1", "AAA"), new MyData("3", "CCC"), };
var updateResponse = await client.AwaitResponse(
DataChangeRequest.Update(updateItems),
o => o.WithTarget(new ClientAddress())
);
// Verify updated data
data = (
await clientWorkspace
.GetObservable<MyData>()
.Timeout(10.Seconds())
.FirstOrDefaultAsync(x => x?.Count == 3)
)
.OrderBy(a => a.Id)
.ToArray();
Data models are created as standard record types using XML comments to document. MeshWeaver.Data supports validation using standard .NET data annotations from the System.ComponentModel.DataAnnotations namespace:
using System.ComponentModel.DataAnnotations;
/// <summary>
/// Represents a product in the system with validation attributes.
/// </summary>
public record Product
{
/// <summary>
/// Gets or sets the unique identifier for the product.
/// </summary>
[Required]
[StringLength(10, MinimumLength = 3)]
public string Id { get; init; }
/// <summary>
/// Gets or sets the display name of the product.
/// </summary>
[Required(ErrorMessage = "Product name is required")]
[StringLength(100)]
public string Name { get; init; }
/// <summary>
/// Gets or sets the product description.
/// </summary>
[StringLength(500)]
public string Description { get; init; }
/// <summary>
/// Gets or sets the price of the product.
/// </summary>
[Range(0.01, 10000.00, ErrorMessage = "Price must be between $0.01 and $10,000.00")]
public decimal Price { get; init; }
/// <summary>
/// Gets or sets the product category.
/// </summary>
[Required]
public string Category { get; init; }
/// <summary>
/// Gets or sets the product inventory count.
/// </summary>
[Range(0, 1000)]
public int StockQuantity { get; init; }
}
MeshWeaver.Data allows accessing data streams from remote sources using the GetRemoteStream() method. This is particularly useful for accessing data from specific domains or partitioned data sources:
// Access a remote stream of data
// This is typically used in domain service tests and layout service tests
var remoteStream = workspace.GetRemoteStream<EntityType>(domainAddress);
// Process the remote stream data
await remoteStream
.Timeout(TimeSpan.FromSeconds(10))
.Select(entities => ProcessEntities(entities))
.Subscribe(
result => Logger.LogInformation($"Processed {result.Count} entities"),
error => Logger.LogError($"Error processing entities: {error.Message}")
);
The GetRemoteStream() method is essential for distributed data scenarios where data lives across different domains or partitions in the MeshWeaver ecosystem.
Remote streams can be updated using the Update method with a lambda expression that modifies the current state.
The Update method accepts a lambda function that:
This pattern enables maintaining consistency across distributed systems while allowing for complex state modifications.
Refer to the for more information about the overall project.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net9.0 net9.0 is compatible. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
Showing the top 4 NuGet packages that depend on MeshWeaver.Data:
| Package | Downloads |
|---|---|
|
MeshWeaver.Layout
Package Description |
|
|
MeshWeaver.Import
Package Description |
|
|
MeshWeaver.AI
Package Description |
|
|
MeshWeaver.Graph
Package Description |
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 3.0.0-preview1 | 263 | 4/16/2026 |
| 2.5.0 | 544 | 11/3/2025 |
| 2.4.0 | 516 | 10/2/2025 |
| 2.3.0 | 506 | 8/4/2025 |
| 2.2.0 | 782 | 7/21/2025 |
| 2.1.0 | 434 | 4/6/2025 |
| 2.0.3 | 733 | 3/24/2025 |
| 2.0.2 | 732 | 3/24/2025 |
| 2.0.1 | 378 | 3/21/2025 |
| 2.0.0 | 425 | 3/20/2025 |
| 2.0.0-preview3 | 357 | 2/28/2025 |
| 2.0.0-Preview2 | 396 | 2/10/2025 |
| 2.0.0-preview1 | 378 | 1/6/2025 |
| 1.0.1 | 359 | 10/8/2024 |
| 1.0.0 | 348 | 10/8/2024 |