Click here to Skip to main content
13,095,921 members (53,565 online)
Click here to Skip to main content
Articles » Database » Database » ADO.NET » Downloads

Stats

169K views
2.9K downloads
182 bookmarked
Posted 24 Oct 2007

Light ORM Library for .NET

, 8 Oct 2010
This article is about the Light Object-Relational Mapping library.
using System;
using System.Data;

namespace Light
{
	/// <summary>
	/// Marks a property or a field as a column.
	/// </summary>
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field,
					Inherited=false, AllowMultiple=false)]
	public class ColumnAttribute : Attribute
	{
		private string name;
		private DbType dbtype;
		private int size;
		private byte precision;
		private byte scale;
		private bool primaryKey;
		private bool autoIncrement;
		
		/// <summary>
		/// Marks a property or a field as a column.
		/// </summary>
		public ColumnAttribute() : this("")
		{
		}
		
		/// <summary>
		/// Marks a property or a field as a column.
		/// </summary>
		/// <param name="name">column name</param>
		public ColumnAttribute(string name)
			: this(name, DbType.Object)
		{
		}
		
		/// <summary>
		/// Marks a property or a field as a column.
		/// </summary>
		/// <param name="dbtype">database data type</param>
		public ColumnAttribute(DbType dbtype) : this("", dbtype)
		{
		}
		
		/// <summary>
		/// Marks a property or a field as a column.
		/// </summary>
		/// <param name="name">column name</param>
		/// <param name="dbtype">database data type</param>
		public ColumnAttribute(string name, DbType dbtype)
			: this(name, dbtype, 0)
		{
		}
		
		/// <summary>
		/// Marks a property or a field as a column.
		/// </summary>
		/// <param name="dbtype">database data type</param>
		/// <param name="size">database data type size</param>
		public ColumnAttribute(DbType dbtype, int size)
			: this("", dbtype, size)
		{
		}
		
		/// <summary>
		/// Marks a property or a field as a column.
		/// </summary>
		/// <param name="name">column name</param>
		/// <param name="dbtype">database data type</param>
		/// <param name="size">database data type size</param>
		public ColumnAttribute(string name, DbType dbtype, int size)
			: base()
		{
			this.name = name;
			this.dbtype = dbtype;
			this.size = size;
		}
		
		/// <summary>
		/// Gets or sets the name of this column.
		/// </summary>
		public string Name
		{
			get { return name; }
			set { name = value; }
		}
		
		/// <summary>
		/// Gets the database data type of this column.
		/// </summary>
		public DbType DBType
		{
			get { return dbtype; }
			set { dbtype = value; }
		}
		
		/// <summary>
		/// Gets or sets the size of the database data type.
		/// </summary>
		public int Size
		{
			get { return size; }
			set { size = value; }
		}
		
		/// <summary>
		/// Gets or sets the precision of the database data type.
		/// </summary>
		public byte Precision
		{
			get { return precision; }
			set { precision = value; }
		}
		
		/// <summary>
		/// Gets or sets the scale of the database data type.
		/// </summary>
		public byte Scale
		{
			get { return scale; }
			set { scale = value; }
		}
		
		/// <summary>
		/// Gets or sets whether this column is a primary key column.
		/// </summary>
		public bool PrimaryKey
		{
			get { return primaryKey; }
			set { primaryKey = value; }
		}
		
		/// <summary>
		/// Gets or sets whether this column is an auto incrementing column.
		/// </summary>
		public bool AutoIncrement
		{
			get { return autoIncrement; }
			set { autoIncrement = value; }
		}
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Sergey Busel
Software Developer (Senior)
United States United States
No Biography provided

You may also be interested in...

Pro
Permalink | Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.170813.1 | Last Updated 8 Oct 2010
Article Copyright 2007 by Sergey Busel
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid