using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.ComponentModel;

[DataObject(true)]
public class Common_AreaData : SqlData
{
    public Common_AreaData()
    {
        DataConnection = ConfigurationManager.ConnectionStrings["ConnString_SEST"].ConnectionString;
        TableName = "Common_Area";
        PrimaryKeyColumnNames = new string[] { "AreaName" };
    }


    [DataObjectMethod(DataObjectMethodType.Select, true)]
    public string[] Select()
    {
        DataTable dt = new DataTable(TableName);

        using (SqlConnection cn = new SqlConnection(DataConnection))
        using (SqlDataAdapter da = new SqlDataAdapter(
            "SELECT * FROM " + TableName , cn))
        {
            da.Fill(dt);
            string[] ar = new string[dt.Rows.Count];
            int i = 0;
            foreach (DataRow dr in dt.Rows) {
                ar[i] = dr.ItemArray[0].ToString();
                i++;
            }

            return ar;

        }
    }

}
