I’m running into an issue with a custom OrmLiteResultsFilter, where I’m getting a NullReferenceException if I run a LoadSelect in the context of the filter, but it works fine when just running a Select.
The intent of my filter is just to exclude items that the user may not have permission to view, though even with just basic population functionality I still get the error.
The filter, with just the basic population functionality, looks like this:
public class SecuredItemResultsFilter : OrmLiteResultsFilter
{
private readonly List<string> permissions;
public SecuredItemResultsFilter(List<string> permissions)
{
this.permissions = permissions;
ResultsFn = SecuredItemFilter;
}
private IEnumerable SecuredItemFilter(IDbCommand dbCmd, Type refType)
{
var typedResults = dbCmd.ExecuteReader().ConvertToList(dbCmd.GetDialectProvider(), refType);
return typedResults;
}
}
And I’m getting a NullReferenceException on line 161 of OrmLiteResultsFilter.cs, inside the GetRefList method, after my filter runs:
var list = (IList)typeof(List<>).GetCachedGenericType(refType).CreateInstance();
Is there anything I should be doing differently in my filter to support loading references, or something else that I’m missing?
I’m using version 4.5.14, and the SqlServer2012Dialect.
Can you provide a full code sample we can run to see the NRE? Ideally a sample that’s runnable in Gistlyn otherwise a complete example we can run is fine.
I tried to get it going in Gistlyn here: http://gistlyn.com/?gist=2b9140fe40bd43682b07f99c3f71d51a
But had some issues running it with any filter in there (Type ‘ServiceStack.OrmLite.OrmLiteState’ in Assembly ‘ServiceStack.OrmLite, Version=4.5.13.0, Culture=neutral, PublicKeyToken=null’ is not marked as serializable.).