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


        instance = new TMSEvolutionOfSocialBehaviour();

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

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

        instance.MapFrom(ds.Tables[0].Rows[0]);
        return(instance);
    }
    public static TMSEvolutionOfSocialBehaviour[] Search(System.Int64?esbBehaviourId, System.Int64?esbSchoolId, System.Int64?esbSchoolSubId, System.Int64?esbStudentLoginId, System.String esbCommonVoluntarily, System.String esbMyPears, System.String esbMyToysWithFriends, System.String esbNeatAndTidy, System.String esbReponsibleAndCareful, System.String esbFollowTeacherInstruction, System.String esbWorkInTimeFrame, System.String esbFollowSchoolNorms, System.String esbLikeComeToSchool, System.String esbParticipateGroupGameActivities, System.String esbAddedByType, System.Int64?esbAddedByLoginId, System.DateTime?esbDate, System.Int32?esbStatus)
    {
        DataSet   ds;
        Database  db;
        string    sqlCommand;
        DbCommand dbCommand;


        db         = DatabaseFactory.CreateDatabase();
        sqlCommand = "[dbo].gspTMSEvolutionOfSocialBehaviour_SEARCH";
        dbCommand  = db.GetStoredProcCommand(sqlCommand, esbBehaviourId, esbSchoolId, esbSchoolSubId, esbStudentLoginId, esbCommonVoluntarily, esbMyPears, esbMyToysWithFriends, esbNeatAndTidy, esbReponsibleAndCareful, esbFollowTeacherInstruction, esbWorkInTimeFrame, esbFollowSchoolNorms, esbLikeComeToSchool, esbParticipateGroupGameActivities, esbAddedByType, esbAddedByLoginId, esbDate, esbStatus);

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


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

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

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

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

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

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

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

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

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

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

        instance = new TMSEvolutionOfSocialBehaviour();

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

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

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