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


        instance = new TMSAdmissionEnquiryDetails();

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

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

        instance.MapFrom(ds.Tables[0].Rows[0]);
        return(instance);
    }
    public static TMSAdmissionEnquiryDetails[] Search(System.Int64?aedEnquiryId, System.String aedChildFirstName, System.String aedChildMiddleName, System.String aedChildLastName, System.DateTime?aedDateOfBirth, System.String aedGender, System.String aedGurdianName, System.String aedAddress, System.String aedCity, System.String aedState, System.String aedProgram, System.String aedPinCode, System.String aedLandLineNo, System.String aedMobileNo, System.String aedEmailId, System.String aedAdminssionClass, System.String aedPercentage, System.Int64?aedCounsellorId, System.String aedRemark, System.String aedComment, System.DateTime?aedDate, System.Int32?aedStatus)
    {
        DataSet   ds;
        Database  db;
        string    sqlCommand;
        DbCommand dbCommand;


        db         = DatabaseFactory.CreateDatabase();
        sqlCommand = "[dbo].gspTMSAdmissionEnquiryDetails_SEARCH";
        dbCommand  = db.GetStoredProcCommand(sqlCommand, aedEnquiryId, aedChildFirstName, aedChildMiddleName, aedChildLastName, aedDateOfBirth, aedGender, aedGurdianName, aedAddress, aedCity, aedState, aedProgram, aedPinCode, aedLandLineNo, aedMobileNo, aedEmailId, aedAdminssionClass, aedPercentage, aedCounsellorId, aedRemark, aedComment, aedDate, aedStatus);

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


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

        // 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_AdmissionEnquiryDetails] in DataSet.");
        }

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

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

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

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

        // 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_AdmissionEnquiryDetails] in DataSet.");

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

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

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

        instance = new TMSAdmissionEnquiryDetails();

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

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

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