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


        instance = new TMSCoScholasticMarksDetails();

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

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

        instance.MapFrom(ds.Tables[0].Rows[0]);
        return(instance);
    }
    public static TMSCoScholasticMarksDetails[] Search(System.Int64?mdMarksDetailsId, System.Int64?mdSkillTypeId, System.Int64?mdSkillTitleId, System.Int64?mdSchoolId, System.Int64?mdSchoolSubId, System.Int64?mdStudentLoginId, System.Int64?mdGradeId, System.Int32?mdGradePoint, System.String mdGradeName, System.String mdObtainMarks, System.String mdTotalMarks, System.String mdDescription, System.DateTime?mdDate, System.Int64?mdAddedById, System.String mdAddedByType, System.Int32?mdStatus)
    {
        DataSet   ds;
        Database  db;
        string    sqlCommand;
        DbCommand dbCommand;


        db         = DatabaseFactory.CreateDatabase();
        sqlCommand = "[dbo].gspTMSCoScholasticMarksDetails_SEARCH";
        dbCommand  = db.GetStoredProcCommand(sqlCommand, mdMarksDetailsId, mdSkillTypeId, mdSkillTitleId, mdSchoolId, mdSchoolSubId, mdStudentLoginId, mdGradeId, mdGradePoint, mdGradeName, mdObtainMarks, mdTotalMarks, mdDescription, mdDate, mdAddedById, mdAddedByType, mdStatus);

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


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

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

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

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

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

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

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

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

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

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

        instance = new TMSCoScholasticMarksDetails();

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

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

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