/* Copyright (C) 2008 - 2011 Jordan Marr
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see . */
using System;
namespace Marr.Data.Mapping
{
///
/// Defines a field as a related entity that needs to be created at filled with data.
///
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = false)]
public class RelationshipAttribute : Attribute, IRelationshipInfo
{
///
/// Defines a data relationship.
///
public RelationshipAttribute()
: this(RelationshipTypes.AutoDetect)
{ }
///
/// Defines a data relationship.
///
///
public RelationshipAttribute(RelationshipTypes relationType)
{
RelationType = relationType;
}
///
/// Defines a One-ToMany data relationship for a given type.
///
/// The type of the child entity.
public RelationshipAttribute(Type entityType)
: this(entityType, RelationshipTypes.AutoDetect)
{ }
///
/// Defines a data relationship.
///
/// The type of the child entity.
/// The relationship type can be "One" or "Many".
public RelationshipAttribute(Type entityType, RelationshipTypes relationType)
{
EntityType = entityType;
RelationType = relationType;
}
#region IRelationshipInfo Members
///
/// Gets or sets the relationship type can be "One" or "Many".
///
public RelationshipTypes RelationType { get; set; }
///
/// Gets or sets the type of the child entity.
///
public Type EntityType { get; set; }
#endregion
}
}