https://github.com/openriaservices/openriaservices.fluentmetadata
FluentMentadata is a Fluent API for defining metadata for Open RIA Services entities
https://github.com/openriaservices/openriaservices.fluentmetadata
dotnet fluent open-ria-services wcf
Last synced: 12 months ago
JSON representation
FluentMentadata is a Fluent API for defining metadata for Open RIA Services entities
- Host: GitHub
- URL: https://github.com/openriaservices/openriaservices.fluentmetadata
- Owner: OpenRIAServices
- Created: 2019-05-15T13:14:05.000Z (about 7 years ago)
- Default Branch: main
- Last Pushed: 2022-10-27T12:24:41.000Z (over 3 years ago)
- Last Synced: 2025-06-15T08:17:11.617Z (about 1 year ago)
- Topics: dotnet, fluent, open-ria-services, wcf
- Language: C#
- Homepage:
- Size: 65.4 KB
- Stars: 2
- Watchers: 5
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Build status
[](https://dev.azure.com/OpenRiaServices/OpenRiaServices/_build/latest?definitionId=3&branchName=master)
Sonarcloud status
[](https://sonarcloud.io/dashboard?id=OpenRIAServices_OpenRiaServices.FluentMetadata)
[](https://sonarcloud.io/dashboard?id=OpenRIAServices_OpenRiaServices.FluentMetadata)
[](https://sonarcloud.io/dashboard?id=OpenRIAServices_OpenRiaServices.FluentMetadata)
[](https://sonarcloud.io/dashboard?id=OpenRIAServices_OpenRiaServices.FluentMetadata)
[](https://sonarcloud.io/dashboard?id=OpenRIAServices_OpenRiaServices.FluentMetadata)
Nuget [](https://www.nuget.org/packages/OpenRiaServices.FluentMetadata)
preview [](https://www.nuget.org/packages/OpenRiaServices.FluentMetadata)
# OpenRiaServices.FluentMetadata
FluentMentadata is a Fluent API for defining metadata for Open RIA Services entities
With permission of Nikhil Kothari, I've added the source code of Nikhil's Fluent API for defining WCF Ria Services Metadata to RIA Services Contrib.
I've made a couple of changes. Most noticeable is the ability to attach a MetadataClass to your domain service using the FluentMetadata attribute. This class mimics the OnModelCreating method in EntityFramework DbContext and allows you to instantiate your Metadata classes.
The main advantage of this package is that it allows you to separate your datamodel and metadata in separate projects/assemblies. This is not possible with the standard RIA services approach of buddy classes. These have to be defined in the same project as your datamodel. The drawbacks of this are a pollution of your datamodel and (most importantly) that your datamodel project becomes dependent on RIA services-specific assemblies. With the FluentMetadata package you can define metadata in any assembly you like.
## Download
The package is available as a [Nuget package](https://www.nuget.org/packages/OpenRiaServices.FluentMetadata).
Last nuget release [](https://www.nuget.org/packages/OpenRiaServices.FluentMetadata)
Last preview release [](https://www.nuget.org/packages/OpenRiaServices.FluentMetadata)
## Using FluentMetadata
* Install the FluentMetadata Nuget package (or download its source code)
* Define a MetadataConfiguration class containing the fluent metadata for your entities. For example:
```csharp
public class FluentMetadataConfiguration : IFluentMetadataConfiguration
{
public void OnTypeCreation(MetadataContainer metadataContainer)
{
metadataContainer.Entity().Projection(x => x.SomeProperty).Exclude();
}
}
```
* Alternatively, you can define the metadata for each entity in separate MetadataClass classes. For example
```csharp
public class FooMetadata : MetadataClass
{
public FooMetadata()
{
this.Projection(x => x.ExcludedString).Exclude();
this.Validation(x => x.RequiredString).Required();
this.Validation(x => x.RegularExpressionString).RegularExpression("[a-z](a-z)");
}
}
```
* ... and instantiate it from your FluentMetadataConfiguration class, like so:
```csharp
public class FluentMetadataConfiguration : IFluentMetadataConfiguration
{
public void OnTypeCreation(MetadataContainer metadataContainer)
{
metadataContainer.Add(new FooMetadata());
}
}
```
* ... both mechanisms can be combined.
* Lastly, add the FluentMetadata attribute to your domain service:
```csharp
[EnableClientAccess()]
[FluentMetadata(typeof(FluentMetadataConfiguration))]
public class FluentMetadataTestDomainService : DomainService
{
}
```
## Sample project
Look into the FluentMetadata.Tests folder
## Previous versions
* The version for WCF Ria Services can be found in [riaservicescontrib
](https://github.com/OpenRIAServices/riaservicescontrib)
* The original version is available [here](http://www.nikhilk.net/RIA-Services-Fluent-Metadata-API.aspx).