Add every ScriptableObject to a dictionary?

Hi. I am trying to make an item system. I got the inventory down. And i am making a way to get any item using a variable attached to all ScriptableObjects called ID. And i want to be able to find the ScriptableObject that has the ID. And the best way to do it that i found was to use a Dictionary.
Here’s my ScriptableObject script:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

[CreateAssetMenu]
public class Items : ScriptableObject {

	public Sprite itemSprite;
	public string itemName;
	public int itemId;
}

But i cannot add the item to a Dictionary inside the ScriptableObject class. So. Any idea on how to do this?
The dictionary i am trying to add the item to takes an Int and a String. The int is the ID. And the string is the name

I wouldn’t use a dictionary, as it isn’t much faster than a simple

        public List<Item> ItemsList;
        public Item GetItem(int ID)
        {
            return ItemsList.Find(item => item.ID == ID);
        }

Now if your problem is adding the objects, then you need to make sure you are creating instances, and if you are doing so in the editor, you will need a custom editor window or inspector to create them. You can code up an inspector for the ItemDatabase class you make, then have inside your inspector a way to create and save the assets.

Like this

public int IDs;
public void CreateNew()
{
   Item tempItem;
   AssetDatabase.CreateAsset(tempItem = CreateInstance<Item>(), "Assets/Resources/Items/" + "Item_" + IDs++.ToString() + ".asset");
   ItemsList.Add(tempItem);
}

or

public int IDs;
public void Init()
{
   AssetDatabase.CreateAsset(CreateInstance<ItemDatabase>(), "Assets/Resources/" + "ItemDatabase" + ".asset");
}
public void AddNew()
{
   AssetDatabase.AddObjectToAsset(CreateInstance<Item>(), "Assets/Resources/ + "ItemDatabase" + ".asset");
}

After the object exists, in your OnGUI of your custom inspector you can easily have an expanding list by saying.

void OnGUI()
{
       ItemDatabase Items = target as ItemDatabase;
       EditorGUILayout.BeginVertical();
       for (int i = 0; i < Items .ItemsList.Count; i++)
       {
              if (Items .ItemsList *!= null)*

{
Items .ItemsList = (Item)EditorGUILayout.ObjectField(“Item”, Items .ItemsList*, typeof(Item), false);*
}
}
if (GUILayout.Button(“Add New”)
{
Items.AddNew();
}
EditorGUILayout.EndVertical();
}