Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit ae87c84

Browse files
committed
Merge pull request #425 from Krnlsoft/patch-1
BugFix: KeyNotFoundException OrmLiteState
2 parents 48b47c6 + 68ab581 commit ae87c84

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/ServiceStack.OrmLite/OrmLiteContext.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,21 +98,24 @@ internal static void SetItem<T>(string key, T value)
9898
public static OrmLiteState CreateNewState()
9999
{
100100
var state = new OrmLiteState();
101-
Instance.Items["OrmLiteState"] = state;
101+
OrmLiteState = state;
102102
return state;
103103
}
104104

105105
public static OrmLiteState GetOrCreateState()
106106
{
107-
return (Instance.Items["OrmLiteState"] as OrmLiteState)
107+
return (OrmLiteState as OrmLiteState)
108108
?? CreateNewState();
109109
}
110110

111111
public static OrmLiteState OrmLiteState
112112
{
113113
get
114114
{
115-
return Instance.Items["OrmLiteState"] as OrmLiteState;
115+
if (Instance.Items.Contains("OrmLiteState"))
116+
return Instance.Items["OrmLiteState"] as OrmLiteState;
117+
else
118+
return null;
116119
}
117120
set
118121
{
@@ -152,4 +155,4 @@ public override string ToString()
152155
return "State Id: {0}".Fmt(Id);
153156
}
154157
}
155-
}
158+
}

0 commit comments

Comments
 (0)