-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace obsolete AssociationAttribute with new EntityAssociationAttri…
…bute on client (#509) Replace obsolete `AssociationAttribute` with new `EntityAssociationAttribute` on client * The client now uses `EntityAssociationAttribute` internally for all logic * The old `AssociationAttribute` is still discovered and mapped to an `EntityAssociationAttribute` in case an old version of the code generation has been used. * Code generation has been updated to generate `EntityAssociationAttribute` instead of `AssociationAttribute`
- Loading branch information
1 parent
34d62dd
commit 6293d33
Showing
74 changed files
with
1,285 additions
and
613 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
src/OpenRiaServices.Client/Framework/EntityAssociationAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
#pragma warning disable CS3015 // Type has no accessible constructors which use only CLS-compliant types | ||
|
||
namespace OpenRiaServices | ||
{ | ||
/// <summary> | ||
/// Used to mark an Entity member as an association | ||
/// </summary> | ||
[AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = true)] | ||
|
||
public sealed class EntityAssociationAttribute : Attribute | ||
#pragma warning restore CS3015 // Type has no accessible constructors which use only CLS-compliant types | ||
{ | ||
/// <summary> | ||
/// Full form of constructor | ||
/// </summary> | ||
/// <param name="name">The name of the association. For bi-directional associations, | ||
/// the name must be the same on both sides of the association</param> | ||
/// <param name="thisKey">List of the property names of the key values on this side of the association</param> | ||
/// <param name="otherKey">List of the property names of the key values on the other side of the association</param> | ||
public EntityAssociationAttribute(string name, string[] thisKey, string[] otherKey) | ||
{ | ||
Name = name ?? throw new ArgumentNullException(nameof(name)); | ||
ThisKeyMembers = thisKey ?? throw new ArgumentNullException(nameof(thisKey)); | ||
OtherKeyMembers = otherKey ?? throw new ArgumentNullException(nameof(otherKey)); | ||
|
||
if (name .Length == 0) | ||
throw new ArgumentException("Name cannot be empty", nameof(name)); | ||
if (thisKey.Length == 0) | ||
throw new ArgumentException("ThisKey cannot be empty", nameof(thisKey)); | ||
if (otherKey.Length == 0) | ||
throw new ArgumentException("OtherKey cannot be empty", nameof(otherKey)); | ||
} | ||
|
||
/// <summary> | ||
/// Gets the name of the association. For bi-directional associations, the name must | ||
/// be the same on both sides of the association | ||
/// </summary> | ||
public string Name { get; } | ||
|
||
/// <summary> | ||
/// Gets or sets a value indicating whether this association member represents | ||
/// the foreign key side of an association | ||
/// </summary> | ||
public bool IsForeignKey { get; set; } | ||
|
||
/// <summary> | ||
/// Gets the collection of individual key members specified in the ThisKey string. | ||
/// </summary> | ||
public IReadOnlyCollection<string> ThisKeyMembers { get; } | ||
|
||
/// <summary> | ||
/// Gets the collection of individual key members specified in the OtherKey string. | ||
/// </summary> | ||
public IReadOnlyCollection<string> OtherKeyMembers { get; } | ||
|
||
/// <summary> | ||
/// Gets or sets the key value on this side of the association | ||
/// </summary> | ||
public string ThisKey => string.Join(",", ThisKeyMembers); | ||
|
||
/// <summary> | ||
/// <see langword="string"/> representation of the key value on the other side of the association | ||
/// </summary> | ||
public string OtherKey => string.Join(",", OtherKeyMembers); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.