How to create a query for a non sql database
can anyone provide some reference for a non-sql query interface design pattern?
For sql based database, the query can be achieved by concatenating the query token. but for non-sql, how to design the query, given that the query can be very complex.
EDIT:
I am using db4o to store some objects, I may need to query according to a specific id, time range, or a combination of both.
How do I create a request method?
public IEnumerable<Foo> GetFoos(int id);
public IEnumerable<Foo> GetFoos(int id, TimeRange range);
To create a lot of overloads it seems silly, what if a new query is needed?
a source to share
In C #, Linq is definitely your best bet. Native queries often fail to optimize, which will cause db4o to wet all objects and actually call the lambda expression on the instance object. This is nothing more than auto-shutdown to linq-to-objects, and is pretty darn slow in comparison. Easy to humidify 60 thousand of our typical objects takes a few seconds.
Hint: A breakpoint in a lambda expression should never be called.
Even when used Db4oTool.exe
as a post-build step for optimizing native queries, even simple queries cause problems when using properties or automatic properties on domain objects.
The linq vendor has always given me the best results. It has the most concise syntax and optimization works. Also, the linq provider is very complete, only it might fall back to linq-to-objects more often than you expect.
Also, it is important that the linq provider has specific DLLs in the project folder. What it does depends on the version a little. If you're using builds> = 14204 , make sure it Mono.Reflection.dll
's in your app folder.
For older versions, all of the following must be present:
Db4obects.Db4o.Instrumentation.dll
Db4objects.Db4o.NativeQueries.dll
Mono.Cecil.dll
Cecil.FlowAnalysis.dll
Note that native queries still require them even in new builds.
a source to share
It looks like db4o uses its own queries, which Versant calls Native Queries (note: there is a separate syntax for .Net and native Java queries ). Sort of:
IObjectContainer container = Database();
container.Query(delegate(Foo foo) {
return foo.id == id;
});
container.Query(delegate(Foo foo) {
return foo.id == id;
},
delegate(Foo foo) {
return range.IsIn(foo.time);
});
a source to share