This question is locked. New answers and comments are not allowed.
I am using the Array Property mapping and it is not honoring the table name that i set.
I specifically set the table name to "Security_UserToUsersGroup" below in mapping configuration, but receive the error:
Telerik.OpenAccess.Exceptions.DataStoreException : Delete all link table rows failed: Telerik.OpenAccess.RT.sql.SQLException: Invalid object name 'Security_UsersGroup_users'.
SQL:
I specifically set the table name to "Security_UserToUsersGroup" below in mapping configuration, but receive the error:
Telerik.OpenAccess.Exceptions.DataStoreException : Delete all link table rows failed: Telerik.OpenAccess.RT.sql.SQLException: Invalid object name 'Security_UsersGroup_users'.
SQL:
CREATE
TABLE
dbo.Security_UserToUsersGroup (
"UsersGroupId"
uniqueidentifier
NOT
NULL
,
"SequenceId"
int
NOT
NULL
,
"Username"
nvarchar(255)
NOT
NULL
,
CONSTRAINT
"PK_UserToUsersGroup"
PRIMARY
KEY
(
"UsersGroupId"
,
"SequenceId"
)
)
C#
/// <summary>
/// A named group for users, which we can define operations on.
/// </summary>
public
class
UsersGroup : INameable
{
///<summary>
/// Create a new instance of <c>UsersGroup</c>
///</summary>
public
UsersGroup()
{
//Users = new string[0];
//AllParents = new HashSet<UsersGroup>().ToList();
//AllChildren = new HashSet<UsersGroup>().ToList();
//DirectChildren = new HashSet<UsersGroup>().ToList();
}
#region [ Fields ]
protected
Guid? parentId;
#endregion
#region [ Properties ]
/// <summary>
/// Gets or sets the id of this entity
/// </summary>
/// <value>The id.</value>
public
virtual
Guid Id {
get
;
set
; }
/// <summary>
/// Gets or sets the name of this entity.
/// </summary>
/// <value>The name.</value>
/// <remarks>
/// The name can be set only on creation, and is not changed
/// afterward.
/// </remarks>
public
virtual
string
Name {
get
;
set
; }
/// <summary>
/// Gets or sets the users.
/// </summary>
/// <value>The users.</value>
public
virtual
string
[] Users {
get
;
set
; }
/// <summary>
/// Gets or sets the parent of this group
/// </summary>
/// <value>The parent.</value>
public
virtual
UsersGroup Parent {
get
;
set
; }
/// <summary>
/// Gets or sets the direct children of this group (nested one level)
/// </summary>
/// <value>The directChildren.</value>
public
virtual
IList<UsersGroup> DirectChildren {
get
;
set
; }
/// <summary>
/// Gets or sets all children of this users group, at all nesting levels
/// </summary>
/// <value>All children.</value>
public
virtual
IList<UsersGroup> AllChildren {
get
;
set
; }
/// <summary>
/// Gets or sets all parent of this users group, at all nesting levels
/// </summary>
/// <value>All children.</value>
public
virtual
IList<UsersGroup> AllParents {
get
;
set
; }
#endregion
#region [ DataMapping Configuration ]
public
static
MappingConfiguration<UsersGroup> CreateConfiguration()
{
var mapping =
new
MappingConfiguration<UsersGroup>();
mapping.MapType(c =>
new
{
Id = c.Id,
Name = c.Name,
ParentId = c.parentId
}).ToTable(MappingTables.UsersGroups);
mapping.HasProperty(c => c.Id).IsIdentity(KeyGenerator.Guid);
mapping.HasProperty(c => c.Name).IsNotNullable().HasLength(255);
mapping.HasProperty(c => c.Users)
.WithSequenceColumn(
"SequenceId"
)
.WithArrayValue(
"Username"
)
.WithForeignKey(
"UsersGroupId"
)
.WithTable(
"Security_UserToUsersGroups"
);
mapping.HasAssociation(p => p.Parent)
.WithOpposite(c => c.DirectChildren)
.HasConstraint((p, c) => p.parentId == c.Id)
.WithLoadBehavior(Telerik.OpenAccess.LoadBehavior.Lazy)
.IsManaged();
mapping.HasAssociation(c => c.AllChildren)
.WithOpposite(e => e.AllParents)
.WithLoadBehavior(Telerik.OpenAccess.LoadBehavior.Lazy)
.IsManaged()
.MapJoinTable(MappingTables.UsersGroupsHierarchy, (child, parent) =>
new
{
ParentGroupId = parent.Name,
ChildGroupId = child.Name
});
return
mapping;
}
#endregion
}