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

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


    [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 + " ORDER BY " + PrimaryKeyColumnNames[0], cn))
            "SELECT [Name]" +
            " FROM " + TableName + " ORDER BY " + PrimaryKeyColumnNames[0], cn))
        {
            da.Fill(dt);
            string[] arRtn=null;
            if (dt.Rows.Count > 0) {
                arRtn = new string[dt.Rows.Count];
                for (int i = 0; i < dt.Rows.Count; i++) {
                    arRtn[i] = dt.Rows[i]["Name"].ToString();
                }
            }
            return arRtn;
        }
    }

}
