public static TMSArticleDetails Get(System.Int64 adDetailId)
    {
        DataSet           ds;
        Database          db;
        string            sqlCommand;
        DbCommand         dbCommand;
        TMSArticleDetails instance;


        instance = new TMSArticleDetails();

        db         = DatabaseFactory.CreateDatabase();
        sqlCommand = "[dbo].gspTMSArticleDetails_SELECT";
        dbCommand  = db.GetStoredProcCommand(sqlCommand, adDetailId);

        // Get results.
        ds = db.ExecuteDataSet(dbCommand);
        // Verification.
        if (ds == null || ds.Tables[0].Rows.Count == 0)
        {
            throw new ApplicationException("Could not get TMSArticleDetails ID:" + adDetailId.ToString() + " from Database.");
        }
        // Return results.
        ds.Tables[0].TableName = TABLE_NAME;

        instance.MapFrom(ds.Tables[0].Rows[0]);
        return(instance);
    }
    public static TMSArticleDetails[] Search(System.Int64?adDetailId, System.Int64?adLoginId, System.String adLoginType, System.String adTitle, System.String adSubTitle, System.String adImage, System.String adDescription, System.Int64?adAddedById, System.String adAddedByType, System.DateTime?adDate, System.Int32?adStatus)
    {
        DataSet   ds;
        Database  db;
        string    sqlCommand;
        DbCommand dbCommand;


        db         = DatabaseFactory.CreateDatabase();
        sqlCommand = "[dbo].gspTMSArticleDetails_SEARCH";
        dbCommand  = db.GetStoredProcCommand(sqlCommand, adDetailId, adLoginId, adLoginType, adTitle, adSubTitle, adImage, adDescription, adAddedById, adAddedByType, adDate, adStatus);

        ds = db.ExecuteDataSet(dbCommand);
        ds.Tables[0].TableName = TABLE_NAME;
        return(TMSArticleDetails.MapFrom(ds));
    }
    public static TMSArticleDetails[] MapFrom(DataSet ds)
    {
        List <TMSArticleDetails> objects;


        // Initialise Collection.
        objects = new List <TMSArticleDetails>();

        // Validation.
        if (ds == null)
        {
            throw new ApplicationException("Cannot map to dataset null.");
        }
        else if (ds.Tables[TABLE_NAME].Rows.Count == 0)
        {
            return(objects.ToArray());
        }

        if (ds.Tables[TABLE_NAME] == null)
        {
            throw new ApplicationException("Cannot find table [dbo].[TMS_ArticleDetails] in DataSet.");
        }

        if (ds.Tables[TABLE_NAME].Rows.Count < 1)
        {
            throw new ApplicationException("Table [dbo].[TMS_ArticleDetails] is empty.");
        }

        // Map DataSet to Instance.
        foreach (DataRow dr in ds.Tables[TABLE_NAME].Rows)
        {
            TMSArticleDetails instance = new TMSArticleDetails();
            instance.MapFrom(dr);
            objects.Add(instance);
        }

        // Return collection.
        return(objects.ToArray());
    }
    public static TMSArticleDetails[] MapFrom(DataSet ds)
    {
        List<TMSArticleDetails> objects;

        // Initialise Collection.
        objects = new List<TMSArticleDetails>();

        // Validation.
        if (ds == null)
        throw new ApplicationException("Cannot map to dataset null.");
        else if (ds.Tables[TABLE_NAME].Rows.Count == 0)
        return objects.ToArray();

        if (ds.Tables[TABLE_NAME] == null)
        throw new ApplicationException("Cannot find table [dbo].[TMS_ArticleDetails] in DataSet.");

        if (ds.Tables[TABLE_NAME].Rows.Count < 1)
        throw new ApplicationException("Table [dbo].[TMS_ArticleDetails] is empty.");

        // Map DataSet to Instance.
        foreach (DataRow dr in ds.Tables[TABLE_NAME].Rows)
        {
            TMSArticleDetails instance = new TMSArticleDetails();
            instance.MapFrom(dr);
            objects.Add(instance);
        }

        // Return collection.
        return objects.ToArray();
    }
    public static TMSArticleDetails Get(System.Int64 adDetailId)
    {
        DataSet ds;
        Database db;
        string sqlCommand;
        DbCommand dbCommand;
        TMSArticleDetails instance;

        instance = new TMSArticleDetails();

        db = DatabaseFactory.CreateDatabase();
        sqlCommand = "[dbo].gspTMSArticleDetails_SELECT";
        dbCommand = db.GetStoredProcCommand(sqlCommand, adDetailId);

        // Get results.
        ds = db.ExecuteDataSet(dbCommand);
        // Verification.
        if (ds == null || ds.Tables[0].Rows.Count == 0) throw new ApplicationException("Could not get TMSArticleDetails ID:" + adDetailId.ToString()+ " from Database.");
        // Return results.
        ds.Tables[0].TableName = TABLE_NAME;

        instance.MapFrom( ds.Tables[0].Rows[0] );
        return instance;
    }