Hello guys!
I have a not very big, but frustrating problem. I am working with sqlite databases and I do some simple operations like retrieving collection of instances of domain model types. I'm doing it in this fashion :
public
List<T> FindAll()
{
ProgramsModel context = ContextProvider.GetProgramsContext();
using
(context)
{
return
context.GetAll<T>().ToList();
}
}
public
class
ContextProvider
{
public
static
string
ProgramsConnectionString {
get
;
set
; }
public
static
string
DllPath {
get
;
set
; }
public
static
ProgramsModel InitProgramsContext()
{
XmlMetadataSource metadataSource =
XmlMetadataSource.FromAssemblyResource(Assembly.LoadFrom(
DllPath +
"BanTester.Repositories.dll"
),
"ProgramModel.rlinq"
);
BackendConfiguration backendConfiguration =
new
BackendConfiguration {Backend =
"sqlite"
};
return
new
ProgramsModel(
ProgramsConnectionString, backendConfiguration, metadataSource);
}
public
static
ProgramsModel GetProgramsContext()
{
return
InitProgramsContext();
}
}
In the first line of the method body I'm initializing a new OpenAccessContext manually (Connection sting, metadata, backend).
So, I am successful with this operation, but I was counting that with disposing the context the connection to the database will be closed.
And here is the problem : when trying to delete the database I'am receiving an exception that the file is used by another process. I am pretty sure that other parts of my application are not keeping a handle to the file. Can you give me directions to where the problem might be?