Here is the diff for comments, but I've also attached the gzipped patch:
hopefully it will apply cleanly on r1244.
---
.../CodeTextGenerator/CodeGenerator.cs | 4 +++-
src/DbMetal/Parameters.cs | 7 +++++++
2 files changed, 10 insertions(+), 1 deletions(-)
diff --git a/src/DbMetal/Generator/Implementation/CodeTextGenerator/CodeGenerator.cs b/src/DbMetal/Generator/Implementation/CodeTextGenerator/CodeGenerator.cs
index 77a6fee..041d238 100644
--- a/src/DbMetal/Generator/Implementation/CodeTextGenerator/CodeGenerator.cs
+++ b/src/DbMetal/Generator/Implementation/CodeTextGenerator/CodeGenerator.cs
@@ -95,7 +95,9 @@ namespace DbMetal.Generator.Implementation.CodeTextGenerator
{
using (WriteNamespace(codeWriter, contextNamespace))
{
- WriteDataContext(codeWriter, dbSchema, context);
+ if (!context.Parameters.NoDataContext) {
+ WriteDataContext(codeWriter, dbSchema, context);
+ }
WriteClasses(codeWriter, dbSchema, context);
}
}
diff --git a/src/DbMetal/Parameters.cs b/src/DbMetal/Parameters.cs
index 0391667..e38badc 100644
--- a/src/DbMetal/Parameters.cs
+++ b/src/DbMetal/Parameters.cs
@@ -215,6 +215,13 @@ namespace DbMetal
public bool ReadLineAtExit { get; set; }
/// <summary>
+ /// avoid generating the DataContext subclass with specialized table accessors
+ /// DbLinq specific
+ /// </summary>
+ [Option("Do not generate the specialized DataContext subclass.", Group = 4)]
+ public bool NoDataContext { get; set; }
+
+ /// <summary>
/// specifies a provider (which here is a pair or ISchemaLoader and IDbConnection implementors)
/// SQLMetal compatible
/// </summary>
--
--
Buongiorno.
Complimenti per l'ottima scelta.
Thanks,
- Jon
Hi,
I can explain that. We have a framework were we generate the code in
separate files and if every file contains a copy of the DataContext
subclass we end with multiple copies of the same code.
Now, why generate code in separate files? We have several reasons:
1) better output from SCM history and diffs
2) 1-to-1 mapping to other generated files (we also generate XML
forms, proxy code and so on)
3) even if we have only 1 PostgreSQL database we like to place the
generated classes in different namespaces because some tables are
generic and part of a framework while others are specific to the
application
We can just keep our own version of DbMetal but if the changes don't
break anything and are generic enough to be useful, why not upstream?
federico
--
Federico Di Gregorio http://people.initd.org/fog
Debian GNU/Linux Developer f...@debian.org
INIT.D Developer f...@initd.org
E tu usa il prefisso corretto Re: non R:, questa è una ML seria.
-- cosmos, su debian-italian
Ah.
Well then, unify the two patches. :-)
Specifically, the specialized database generation logic should also use
the EntityInterfaces type (which should likely be simplified to -type or
something). That way a single option controls what types are generated,
and by implication will control whether the specialized DataContext is
generated (or not, again, based on the type's name).
This would be straightforward and easily documentable (I hope).
- Jon