-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Metadata - Providers (and the default Fluent API) #2
Comments
@masbicudo , I am not really sure about what how to implement this fluent API. In Entity Framework, there's no However, Gearz doesn't work that way. There's no However, things are less fluent with So I think that entities and properties should be implicitly added when you reference tem.. like this: meta.Entity(); The above line is all it takes to add a Contacts entity. If I reference it again, it will just take the previously added contact, not add a new one..
The above line states that Contact, that has been implicitly added before, has a property called Name. If we want to make it required.. We can put this in another line (or in the same):
All metadata inside
|
I think that repetitions should be avoided:
Or making a generic interface:
If that doesn't look good, then I'm fine with repeated things. As you said, the method is to state that something exist, not to add it. Another great idea would be just to reuse the definitions given by other frameworks, such as EntityFramework or nHibernate, as these entities are going to be handled by a persistence layer anyway... the objective is to make things less repetitive... so, if we can make Of course these would be in different projects (so that we can make nuget packages for them separately) |
I agree with the non-repetitive thinking. Actually I think I liked the idea of separating metadata provider for each of the entities.. We'd have to think about it more thoughly.. but the advantage is that, given that We could have an interface for the overall metadata provider, like I'm also kin of the idea of adding each |
We could rename this isse to Do you agree? |
Sure |
Gearz applications get metadata through classes that implement the
IMetadataProvider
interface. It's possible to implement providers that obtain metadata from a variaty of sources, including JSON, XML, databases and so forth. However, the recommended provider for the majority of applications is theFluentMetadataProvider
, that allows you to define metadata in a type-safe way.The
FluentMetadataProvider
class exposes a fluent API that is very simillar to Entity Framework.Example:
How it works
Calling the
Entity()
function defines that an entity existis. Subsequent calls will have no effect. The same is truth for properties as well. For instance, the line:Is defining that Contact exists as an Entity, that it has a property called Name, and that property is required and it's max length is 30.
The text was updated successfully, but these errors were encountered: