Closed AndreiBozantan closed 4 years ago
queries
This is better. Only thing is that I would prefer if
GetQueryStatement
was not part of the public API, since it's never called outside theBuildQueryStatement
method.We could have the
DQuery
interface exposeBuildQueryStatement
only and instead haveGetQueryStatement
implemented in an abstract base classDQueryBase
(or whatever) as a protected member. The ABC would also provide the default impl forBuildQueryStatement
.Then the query implementations would derive from the
DQueryBase
instead of implementing the interface directly.Something like this:
public interface DQuery<TRow> { public string BuildQueryStatement(...); public TRow ParseRow(...); } public abstract class DQueryBase<TRow> : DQuery<TRow> { public virtual string BuildQueryStatement(...) => GetQueryStatement(...); protected abstract string GetQueryStatement(...); public TRow ParseRow(...); }
What do you think?
I am not sure that this will work. There are some query implementations (e.g. Min
) that implement the DQuery
interface multiple times.
queries
This is better. Only thing is that I would prefer if
GetQueryStatement
was not part of the public API, since it's never called outside theBuildQueryStatement
method. We could have theDQuery
interface exposeBuildQueryStatement
only and instead haveGetQueryStatement
implemented in an abstract base classDQueryBase
(or whatever) as a protected member. The ABC would also provide the default impl forBuildQueryStatement
. Then the query implementations would derive from theDQueryBase
instead of implementing the interface directly. Something like this:public interface DQuery<TRow> { public string BuildQueryStatement(...); public TRow ParseRow(...); } public abstract class DQueryBase<TRow> : DQuery<TRow> { public virtual string BuildQueryStatement(...) => GetQueryStatement(...); protected abstract string GetQueryStatement(...); public TRow ParseRow(...); }
What do you think?
I am not sure that this will work. There are some query implementations (e.g.
Min
) that implement theDQuery
interface multiple times.
I thought a little bit more about it, and I think that we can use both deriving from ABC, in order to implement the BuildQueryStatement
and implementing the DQuery
interface for ParseRow
multiple times. I will do the changes.
Here is a list with some of the changes:
DQuery
to get the table and column names in theBuildQueryStatement
method instead of the constructor;Exec
in theExplorerContext
interface;ExplorerContext.Exec
implementations, instead of doing it earlier in the constructor;DConnection
interface;TestScope
class;ExplorerContext
in the components, by defining a dependency injected property (ExplorerComponentBase.Context
); this removes the necessity of injecting the context value in the constructor;