aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.DataStore.EF/EFDataStoreCollection.cs
diff options
context:
space:
mode:
authorRoy Ben Shabat <Roy.mail.net@gmail.com>2020-10-23 03:13:09 +0300
committerRoy Ben Shabat <Roy.mail.net@gmail.com>2020-10-23 03:13:09 +0300
commit8d2b13aaa70bc6a8f521df4eab165caf078c33fa (patch)
tree325567b00d55fa751da7492be067e7878b132e28 /Software/Visual_Studio/Tango.DataStore.EF/EFDataStoreCollection.cs
parenta79900d579ae9f624b35aa933784e4e0f0c65d03 (diff)
downloadTango-8d2b13aaa70bc6a8f521df4eab165caf078c33fa.tar.gz
Tango-8d2b13aaa70bc6a8f521df4eab165caf078c33fa.zip
DataStore Improvements.
Diffstat (limited to 'Software/Visual_Studio/Tango.DataStore.EF/EFDataStoreCollection.cs')
-rw-r--r--Software/Visual_Studio/Tango.DataStore.EF/EFDataStoreCollection.cs29
1 files changed, 26 insertions, 3 deletions
diff --git a/Software/Visual_Studio/Tango.DataStore.EF/EFDataStoreCollection.cs b/Software/Visual_Studio/Tango.DataStore.EF/EFDataStoreCollection.cs
index eab6ef377..afec27417 100644
--- a/Software/Visual_Studio/Tango.DataStore.EF/EFDataStoreCollection.cs
+++ b/Software/Visual_Studio/Tango.DataStore.EF/EFDataStoreCollection.cs
@@ -53,23 +53,46 @@ namespace Tango.DataStore.EF
public T Get<T>(string key)
{
- return (T)Get(key);
+ return (T)Get(key, null);
+ }
+
+ public T Get<T>(string key, T defaultValue)
+ {
+ return (T)Get(key, (object)defaultValue);
}
public object Get(string key)
{
- return GetItem(key).Value;
+ return Get(key, null);
+ }
+
+ public object Get(string key, object defaultValue)
+ {
+ return GetItem(key, defaultValue).Value;
}
public IDataStoreItem GetItem(string key)
{
+ return GetItem(key, null);
+ }
+
+ public IDataStoreItem GetItem(string key, object defaultValue)
+ {
using (var db = ObservablesContext.CreateDefault())
{
var item = db.DataStoreItems.SingleOrDefault(x => x.CollectionName == Name && x.Key == key);
if (item == null)
{
- throw new KeyNotFoundException("The specified data store key was not found.");
+ if (defaultValue == null)
+ {
+ throw new KeyNotFoundException("The specified data store key was not found.");
+ }
+ else
+ {
+ Put(key, defaultValue);
+ return GetItem(key);
+ }
}
return item.ToDataStoreItem();