DomainService (with [EnableClientAccess])
[ServiceOperation] for generic operations
[Query] or Get...(args); returning T, IEnumerable
Use HasSideEffects = true to send query as post.
[Insert] or Insert...(args)
[Update] or Update...(args)
[Delete] or Delete...(args)
Resolve is used for optimistic concurrency resolution.
[Custom] methods return void and take an entity as the first parameter but is not one of the above. They are change tracked etc.
[ServiceOperation] are more like web methods.
Entities may inherit from entity, but must have a key if used in an IEnumerable collection.
[Include] is used to link classes together, for example Job and JobNotes. This will ensure the code generator will copy JobNotes to the client project. This can also be used for data denormalisation on the Job class's metadata class:
[Include("NoteDateTime", "DateTime")]
public JobNotes JobNotes;
This will result in a new property on the Job class on the client called NoteDateTime and only serialise the DateTime of the job note, not the detail.
[MetadataType] can be used to specify another class whose attributes are merged with the main class. Attributes on properties in the metadata class are merged with those on the main class. This is useful for modifying the attributes on compiler generated code through partial classes.
Client side:
Perform linq operations to filter (if required) the query, using the query as IEnumerable, then use the DomainContext's Load methods to load the data asynchronously.
DataGrid / DataForm / FieldLabel:
[Bindable] specifies whether a property is bindable or not.
[Display(Name, Description)]
Validation:
[StringLength]
[Required]
[Range]
[RegularExpression]
[CustomValidation]
[DataType]
Custom validation attributes can be made by deriving from ValidationAttribute.
Authorisation:
[RequiresAuthentication]
Shared code:
Code file should be called xxxxx.shared.cs, then use [Shared].
Use [CustomValidation] for validation code (see this).
A useful application of shared code is to add a partial class that extends the functionality of a generated class, i.e. to add a new calculated property. This class will then be copied to the client and the calculated property will be in both client and server code.
More detail:
See this page.
0 comments:
Post a Comment