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


        instance = new TMSStudentDetails();

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

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

        instance.MapFrom(ds.Tables[0].Rows[0]);
        return(instance);
    }
    public static TMSStudentDetails[] Search(System.Int64?sdStudentDetailsId, System.Int64?sdApplicationId, System.Int64?sdLoginId, System.Int64?sdParentId, System.String sdStudentPNRId, System.String sdStudentClassId, System.String sdFormNo, System.String sdFirstName, System.String sdMiddleName, System.String sdLastName, System.DateTime?sdDateOfBirth, System.String sdPlaceOfBirth, System.String sdAcadamicYear, System.String sdBloodGroup, System.String sdStudentImage, System.String sdNationality, System.String sdGender, System.String sdCaste, System.String sdSubCaste, System.DateTime?sdDateOfAdmission, System.String sdMotherTongue, System.Int64?sdSchoolCategoryId, System.Int64?sdSchoolSubCatId, System.String sdTransportStatus, System.String sdMedicalProblem, System.String sdLastSchoolAttended, System.String sdLastClassAttended, System.String sdLastClassPer, System.Int64?sdAddressId, System.String sdAgeProof, System.String sdLastProgressReportCard, System.String sdOriginalSchoolLC, System.String sdPassportAndVisa, System.String sdRegistrationLetter, System.Int32?sdStatus)
    {
        DataSet   ds;
        Database  db;
        string    sqlCommand;
        DbCommand dbCommand;


        db         = DatabaseFactory.CreateDatabase();
        sqlCommand = "[dbo].gspTMSStudentDetails_SEARCH";
        dbCommand  = db.GetStoredProcCommand(sqlCommand, sdStudentDetailsId, sdApplicationId, sdLoginId, sdParentId, sdStudentPNRId, sdStudentClassId, sdFormNo, sdFirstName, sdMiddleName, sdLastName, sdDateOfBirth, sdPlaceOfBirth, sdAcadamicYear, sdBloodGroup, sdStudentImage, sdNationality, sdGender, sdCaste, sdSubCaste, sdDateOfAdmission, sdMotherTongue, sdSchoolCategoryId, sdSchoolSubCatId, sdTransportStatus, sdMedicalProblem, sdLastSchoolAttended, sdLastClassAttended, sdLastClassPer, sdAddressId, sdAgeProof, sdLastProgressReportCard, sdOriginalSchoolLC, sdPassportAndVisa, sdRegistrationLetter, sdStatus);

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


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

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

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

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

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

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

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

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

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

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

        instance = new TMSStudentDetails();

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

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

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