using System;

namespace LinqToDB.Mapping
{
	/// <summary>
	/// Marks target column as identity column with value, generated on database side during insert operations.
	/// Identity columns will be ignored for insert and update operations with implicit column list like
	/// <see cref="DataExtensions.Insert{T}(IDataContext, T, string?, string?, string?, string?, TableOptions)"/> or
	/// <see cref="DataExtensions.Update{T}(IDataContext, T, string?, string?, string?, string?, TableOptions)"/> methods.
	/// </summary>
	[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = true)]
	public class IdentityAttribute : MappingAttribute
	{
		/// <summary>
		/// Creates attribute instance.
		/// </summary>
		public IdentityAttribute()
		{
		}

		/// <summary>
		/// Creates attribute instance.
		/// </summary>
		/// <param name="configuration">Mapping schema configuration name. See <see cref="Configuration"/>.</param>
		public IdentityAttribute(string? configuration)
		{
			Configuration = configuration;
		}

		public override string GetObjectID() => Configuration ?? string.Empty;
	}
}
