private void LoadDictionaries() { string sql = "SELECT [ID],[Prefix],[Key],[ParentID] FROM IDTable"; string connectionString = ConfigurationManager.ConnectionStrings[_databaseConnectionStringName].ConnectionString; List <IDTableEntry> idTableEntries = new List <IDTableEntry>(); using (SqlConnection connection = new SqlConnection(connectionString)) { connection.Open(); using (SqlCommand command = new SqlCommand(sql, connection)) { using (SqlDataReader reader = command.ExecuteReader()) { while (reader.Read()) { idTableEntries.Add( new IDTableEntry( reader.GetString(1), reader.GetString(2), ID.Parse(reader.GetGuid(0)), ID.Parse(reader.GetGuid(3)), "" )); } } } } _idByKey = new Dictionary <IdTableStringKey, IDTableEntry>(); _idById = new Dictionary <IdTableIdKey, List <IDTableEntry> >(); foreach (IDTableEntry entry in idTableEntries) { IdTableStringKey idTableStringKey = new IdTableStringKey(entry.Prefix, entry.Key); if (!_idByKey.ContainsKey(idTableStringKey)) { _idByKey.Add(idTableStringKey, entry); } IdTableIdKey idTableIdKey = new IdTableIdKey(entry.Prefix, entry.ID.Guid); if (!_idById.ContainsKey(idTableIdKey)) { _idById.Add(idTableIdKey, new List <IDTableEntry> { entry }); } else { _idById[idTableIdKey].Add(entry); } } }
public override bool Equals(object obj) { IdTableStringKey idTableStringKey = obj as IdTableStringKey; if (idTableStringKey != null) { return(idTableStringKey.InternalKey == this.InternalKey); } return(false); }
public override IDTableEntry GetID(string prefix, string key) { var idTableStringKey = new IdTableStringKey(prefix, key); if (_idByKey.ContainsKey(idTableStringKey)) { return _idByKey[idTableStringKey]; } return null; }
public override IDTableEntry GetID(string prefix, string key) { var idTableStringKey = new IdTableStringKey(prefix, key); if (_idByKey.ContainsKey(idTableStringKey)) { return(_idByKey[idTableStringKey]); } return(null); }
public IDTableEntry GetID(string prefix, string key) { var idTableStringKey = new IdTableStringKey(prefix, key); //if (_idByKey.ContainsKey(idTableStringKey)) //{ // return _idByKey[idTableStringKey]; //} _idByKey[idTableStringKey] = IDTable.GetID(prefix, key); return _idByKey[idTableStringKey]; }
public IDTableEntry GetID(string prefix, string key) { var idTableStringKey = new IdTableStringKey(prefix, key); //if (_idByKey.ContainsKey(idTableStringKey)) //{ // return _idByKey[idTableStringKey]; //} _idByKey[idTableStringKey] = IDTable.GetID(prefix, key); return(_idByKey[idTableStringKey]); }
public override void Add(IDTableEntry entry) { var idTableStringKey = new IdTableStringKey(entry.Prefix, entry.Key); if (!_idByKey.ContainsKey(idTableStringKey)) { _idByKey[idTableStringKey] = entry; } var key = new IdTableIdKey(entry.Prefix, entry.ID.Guid); if (!_idById.ContainsKey(key)) { _idById.Add(key, new List<IDTableEntry> {entry}); } }
public override void Add(IDTableEntry entry) { var idTableStringKey = new IdTableStringKey(entry.Prefix, entry.Key); if (!_idByKey.ContainsKey(idTableStringKey)) { _idByKey[idTableStringKey] = entry; } var key = new IdTableIdKey(entry.Prefix, entry.ID.Guid); if (!_idById.ContainsKey(key)) { _idById.Add(key, new List <IDTableEntry> { entry }); } }
internal IDTableEntry Add(string prefix, string key, ID id, ID parentId) { var idTableIdKey = new IdTableIdKey(prefix, id.Guid); var tableEntry = new IDTableEntry(prefix, key, id, parentId, ""); if (!_idById.ContainsKey(idTableIdKey)) { _idById.Add(idTableIdKey, new List <IDTableEntry> { tableEntry }); } var idTableStringKey = new IdTableStringKey(prefix, key); if (!_idByKey.ContainsKey(idTableStringKey)) { _idByKey[idTableStringKey] = tableEntry; } return(IDTable.Add(prefix, key, id, parentId)); }
internal IDTableEntry Add(string prefix, string key, ID id, ID parentId) { var idTableIdKey = new IdTableIdKey(prefix, id.Guid); var tableEntry = new IDTableEntry(prefix, key, id, parentId, ""); if (!_idById.ContainsKey(idTableIdKey)) { _idById.Add(idTableIdKey, new List<IDTableEntry> { tableEntry }); } var idTableStringKey = new IdTableStringKey(prefix, key); if (!_idByKey.ContainsKey(idTableStringKey)) { _idByKey[idTableStringKey] = tableEntry; } return IDTable.Add(prefix, key, id, parentId); }
private void LoadDictionaries() { string sql = "SELECT [ID],[Prefix],[Key],[ParentID] FROM IDTable"; string connectionString = ConfigurationManager.ConnectionStrings[_databaseConnectionStringName].ConnectionString; List<IDTableEntry> idTableEntries = new List<IDTableEntry>(); using (SqlConnection connection = new SqlConnection(connectionString)) { connection.Open(); using (SqlCommand command = new SqlCommand(sql, connection)) { using (SqlDataReader reader = command.ExecuteReader()) { while (reader.Read()) { idTableEntries.Add( new IDTableEntry( reader.GetString(1), reader.GetString(2), ID.Parse(reader.GetGuid(0)), ID.Parse(reader.GetGuid(3)), "" )); } } } } _idByKey = new Dictionary<IdTableStringKey, IDTableEntry>(); _idById = new Dictionary<IdTableIdKey, List<IDTableEntry>>(); foreach (IDTableEntry entry in idTableEntries) { IdTableStringKey idTableStringKey = new IdTableStringKey(entry.Prefix, entry.Key); if (!_idByKey.ContainsKey(idTableStringKey)) { _idByKey.Add(idTableStringKey, entry); } IdTableIdKey idTableIdKey = new IdTableIdKey(entry.Prefix, entry.ID.Guid); if (!_idById.ContainsKey(idTableIdKey)) { _idById.Add(idTableIdKey, new List<IDTableEntry> { entry }); } else { _idById[idTableIdKey].Add(entry); } } }
public override void Remove(string prefix, string key) { var idTableStringKey = new IdTableStringKey(prefix, key); _idByKey.Remove(idTableStringKey); }