1

Bryce: Here are my current functions. With the list in the class, I'm not quite sure how to modify my code.

public void GetMembers()
{
    DatabaseManager.Instance.SQLiteInit();
    MemberList.Clear();
    MemberList= DatabaseManager.Instance.MakeMembersList();
    Debug.Log("How many in the list " + MemberList.Count);
    ShowAllMembers();
}


public void GetEquipment()
{
    DatabaseManager.Instance.SQLiteInit();
    EquipmentList.Clear();
    EquipmentList= DatabaseManager.Instance.MakeEquipmentList();
    Debug.Log("How many in the list " + EquipmentList.Count);
    ShowAllEquipment();
}

Also thought you should see the database function being called.

public List<NewEquipmentClass> MakeEquipmentList()
{
    EquipmentList.Clear();
    mConnection.Open();
    mSQLString = "SELECT * FROM " + SQL_TABLE_EQUIPMENT + " ORDER BY " + COL_EQUIPMENT_ID;
    mCommand.CommandText = mSQLString;
    mCommand.ExecuteNonQuery();
    mReader = mCommand.ExecuteReader();

    while (mReader.Read())
    {
        EquipmentList.Add(new Equipment(mReader.GetString(0), 
                                        mReader.GetString(1)));

        Debug.Log(mReader.GetString(0) + mReader.GetString(1));
    }

    mReader.Close();
    mConnection.Close();
    return EquipmentList;
}

Thanks!

This is the result I am looking for:

Member Name
Member's Equipment
Member's Equipment
Member's Equipment

Member Name
Member's Equipment...
Etc.

I have two lists, one for members and one for equipment. What is the best way to get the type of results above? Thanks!

Ken Gordon
  • 195
  • 6
  • 20
  • What have you tried so far? What types of collections have you tested against? What are the datatypes of the variables you want to store? I would recommend you look into Collections and Enumerables in .NET to understand these. To answer your question though, have a read of this: http://stackoverflow.com/questions/2101069/c-sharp-dictionary-one-key-many-values – DeeKayy90 Dec 06 '16 at 01:05

1 Answers1

3

It looks like you want to create a class called Member that looks something like this

class Member {
    string name;
    List<Equipment> equipment;
}

where Equipment could be an object with a name and stats or whatever you need. And then have a list of them like

List<Member> members;

Obviously you'd want getters/setters/constructor etc. but if implementing this isn't clear to you I'd recommend some fundamentals of c# or Object Oriented learning.

Bryce Rogers
  • 668
  • 1
  • 5
  • 8
  • "Obviously" isn't going to be too obvious to a newb. If you made those class variables public, it could be handled like a basic struct, without a lot of boilerplate code. "Obviously" not the best programming practice, but for a beginner, a start. – Chuck Savage Dec 06 '16 at 04:58
  • Thanks Bryce, that's something I hadn't thought of. I'll give it a go and let you know. – Ken Gordon Dec 08 '16 at 00:04
  • Bryce, the way I had thought previously, which now brings up the question. The data for the list comes from an sqlite database. How then do I add the various things to the list. Here are the functions – Ken Gordon Dec 08 '16 at 00:15