#region Apache Notice
/*****************************************************************************
* $Header: $
* $Revision: $
* $Date: $
*
* iBATIS.NET Data Mapper
* Copyright (C) 2004 - Gilles Bayon
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
********************************************************************************/
#endregion
#region Imports
using System;
using System.Xml.Serialization;
using IBatisNet.Common.Utilities.Objects;
using IBatisNet.DataMapper.MappedStatements;
using IBatisNet.DataMapper.Scope;
#endregion
namespace IBatisNet.DataMapper.Configuration.Statements
{
///
/// Represent a SelectKey tag element.
///
[Serializable]
[XmlRoot("selectKey", Namespace="http://ibatis.apache.org/mapping")]
public class SelectKey : Statement
{
#region Fields
[NonSerialized]
private SelectKeyType _selectKeyType = SelectKeyType.post;
[NonSerialized]
private string _property = string.Empty;
#endregion
#region Properties
///
/// Extend statement attribute
///
[XmlIgnore]
public override string ExtendStatement
{
get { return string.Empty; }
set { }
}
///
/// The property name object to fill with the key.
///
[XmlAttribute("property")]
public string PropertyName
{
get { return _property; }
set { _property = value; }
}
///
/// The type of the selectKey tag : 'Pre' or 'Post'
///
[XmlAttribute("type")]
public SelectKeyType SelectKeyType
{
get { return _selectKeyType; }
set { _selectKeyType = value; }
}
///
/// True if it is a post-generated key.
///
[XmlIgnore]
public bool isAfter
{
get { return _selectKeyType == SelectKeyType.post; }
}
#endregion
#region Constructor (s) / Destructor
///
/// Do not use direclty, only for serialization.
///
public SelectKey():base()
{
}
#endregion
#region Methods
///
///
///
/// The scope of the configuration
override internal void Initialize(ConfigurationScope configurationScope)
{
// the propertyName attribute on the selectKey node is optional
if (PropertyName.Length > 0)
{
// Id is equal to the parent