DBMetal & Aliasing

59 views
Skip to first unread message

Adam Tauno Williams

unread,
Dec 11, 2008, 11:57:27 AM12/11/08
to dbl...@googlegroups.com
I've just started trying out DbLinq, I can generate source for my
database without issue. But I'd like to clean up how the schema is
presented; DbMetal has the option:
/aliases:<file> Use mapping file.
But I can't find any docs on how to construct such an alias file; I
assume I must be googling the wrong terms. I thought perhaps I needed
to make a DBML file and then process that, like -

mono DbMetal.exe /provider=PostgreSql \
/conn="database=OGo;username=OGo;host=localhost" \
/dbml=OGoDB.dbml -database:OGo \
-namespace:Org.OpenGroupware /entityBase:OGoEntity

- but the file it generated is extremely sparse (which is possibly
correct, I guess).

Pascal Craponne

unread,
Dec 11, 2008, 1:05:11 PM12/11/08
to dbl...@googlegroups.com
Hi,

here are two kinds samples of rename files in the source code (in src/DbMetal):
- xml files (DbMetal specific), pgsqlFieldRenames.xml and oraFieldRenames.xml
- DBML files (I started to implement something to get closer to the original SqlMetal), like NorthwindRename.dbml

There are still some problems, but it works fine for columns and classes (less fine for associations).

Pascal.

jabber/gtalk: pas...@jabber.fr
msn: pas...@craponne.org

Adam Tauno Williams

unread,
Dec 19, 2008, 10:04:00 AM12/19/08
to dbl...@googlegroups.com
On Thu, Dec 11, 2008 at 17:57, Adam Tauno Williams
> > I've just started trying out DbLinq, I can generate source for my
> > database without issue. But I'd like to clean up how the schema is
> > presented; DbMetal has the option:
> > /aliases:<file> Use mapping file.
> > But I can't find any docs on how to construct such an alias file; I
> > a ssume I must be googling the wrong terms. I thought perhaps
> > Ineeded
> > >to make a DBML file and then process that, like
> mono DbMetal.exe /provider=PostgreSql
> > /conn="database=OGo;username=OGo;hostlocalhost" \

> > /dbml=OGoDB.dbml -database:OGo \
> > -namespace:Org.OpenGroupware /entityBase:OGoEntity
> > - but the file it generated is extremely sparse (which is possibly
> > correct, I guess).

On Thu, 2008-12-11 at 19:05 +0100, Pascal Craponne wrote:
> here are two kinds samples of rename files in the source code
> (in src/DbMetal):
> - xml files (DbMetal specific), pgsqlFieldRenames.xml and
> oraFieldRenames.xml
> - DBML files (I started to implement something to get closer to the
> original SqlMetal), like NorthwindRename.dbml There are still some
> problems, but it works fine for columns and classes (less fine for
> associations).

Is there a way to generate a default DBML that contains all the data and
then edit it, or do I have to create it from scratch? When I do
"/dbml=OGoDB.dbml" the DBML file is *very* sparse and contains only
references to tables (no references to fields), like:

<Table Name="public.article" Member="Article">
<Type Name="Article" />
</Table>

But if I generate classes they do domain setter/getters for all the
fields.

The alias method (like pgsqlFieldRenames.xml) seems to work for both
fields and tables, so that may be sufficient; just seems like DBML is
the richer solution.

Pascal Craponne

unread,
Dec 19, 2008, 10:33:51 AM12/19/08
to dbl...@googlegroups.com
DBML generated files should be complete, as complete as C# files, since those DBML files can be used as source to generate C#. Isn't it the case for you?

Pascal.

jabber/gtalk: pas...@jabber.fr
msn: pas...@craponne.org



Adam Tauno Williams

unread,
Dec 19, 2008, 11:42:48 AM12/19/08
to dbl...@googlegroups.com
On Fri, 2008-12-19 at 16:33 +0100, Pascal Craponne wrote:
> DBML generated files should be complete, as complete as C# files,
> since those DBML files can be used as source to generate C#. Isn't it
> the case for you?

No.

awilliam@linux-nnci:~/tmp/DbLinq> mono
DbMetal.exe /provider=PostgreSql /conn="database=OGo;username=OGo;host=localhost" -namespace:Org.OpenGroupware /entityBase:OGoEntity /code=OGoDB.cs -database:OGo
awilliam@linux-nnci:~/tmp/DbLinq> wc -l OGoDB.cs
21251 OGoDB.cs

This contains what looks like a full assembly of classes, whereas -

awilliam@linux-nnci:~/tmp/DbLinq> mono
DbMetal.exe /provider=PostgreSql /conn="database=OGo;username=OGo;host=localhost" -namespace:Org.OpenGroupware /entityBase:OGoEntity /dbml=OGoDB.dbml -database:OGo
awilliam@linux-nnci:~/tmp/DbLinq> wc -l OGoDB.dbml
161 OGoDB.dbml

Nothing but:

<?xml version="1.0" encoding="utf-8"?>
<Database xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" Name="&quot;OGo&quot;"
EntityNamespace="Org.OpenGroupware" ContextNamespace="Org.OpenGroupware"
Class="OgO" BaseType="DbLinq.Data.Linq.DataContext"
Provider="PostgreSql"
xmlns="http://schemas.microsoft.com/linqtosql/dbml/2007">
<Table Name="public.address" Member="Address">
<Type Name="Address" />
</Table>
.... more empty <Table ..><Type .../></Table> entries .....
</Database>

So it contains no associations and no field name data.

DbLinq Database mapping generator 2008 version 0.18.0.0
mono-core-2.0.1-18.1.i586
Linux linux-nnci 2.6.25.18-0.2-pae

--
Consonance: an Open Source .NET OpenGroupware client.
Contact:awil...@whitemiceconsulting.com http://freshmeat.net/projects/consonance/

Pascal Craponne

unread,
Dec 19, 2008, 12:09:37 PM12/19/08
to dbl...@googlegroups.com
Can you try using the SVN HEAD sources?

Pascal.

jabber/gtalk: pas...@jabber.fr
msn: pas...@craponne.org



Adam Tauno Williams

unread,
Dec 19, 2008, 1:52:05 PM12/19/08
to dbl...@googlegroups.com
On Fri, 2008-12-19 at 18:09 +0100, Pascal Craponne wrote:
> Can you try using the SVN HEAD sources?

I can try; but it doesn't build on Mono. I opened the VS solution on
Monodevelop just fine, but compilation fails.

I removed all the projects from the solution except DbLinq,
DbLinq.PostgreSql, DbMetal, and System.Data.Linq. Building DbLinq
succeeds but DbLinq.PostgreSql fails with:

[Task:File=, Line=0, Column=0, Type=Error, Priority=Normal,
Description=Friend access was granted to `DbLinq.PostgreSql,
PublicKeyToken=61e015a67077348b', but the output assembly is named
`DbLinq.PostgreSql, Version=0.0.0.0, Culture=neutral,
PublicKeyToken=null'. Try adding a reference to `DbLinq.PostgreSql,
PublicKeyToken=61e015a67077348b' or change the output assembly name to
match it(CS0281)]

Pascal Craponne

unread,
Dec 19, 2008, 4:53:53 PM12/19/08
to dbl...@googlegroups.com
Apparently, the signing key is missing. You need to sign the generated assembly with DbLinq.snk.

Can I ask you to submit a patch once the solution builds? I'll commit it to the repository.

Thanks,

Pascal.

jabber/gtalk: pas...@jabber.fr
msn: pas...@craponne.org



Adam Tauno Williams

unread,
Dec 29, 2008, 10:31:20 AM12/29/08
to dbl...@googlegroups.com
On Fri, 2008-12-19 at 22:53 +0100, Pascal Craponne wrote:
> Apparently, the signing key is missing. You need to sign the generated
> assembly with DbLinq.snk.

> Can I ask you to submit a patch once the solution builds? I'll commit
> it to the repository.

I've got it signing, and have moved onto the next error. :)

I have to add "[assembly: AssemblyKeyFile ("../DbLinq.snk")]" to the
AssemblyInfo.cs of the various projects. And setup Monodevelop to sign
the assemblies (note: this requires working around Monodevelop
bug#461702 <https://bugzilla.novell.com/show_bug.cgi?id=461702>).

Now building DbMetal fails with:

[Task:File=/home/awilliam/Works/DbLinq/dblinq2007-read-only/src/DbMetal/Configuration/ProvidersSection.cs, Line=39, Column=37, Type=Error, Priority=Normal, Description=The type or namespace name `ConfigurationSection' could not be found. Are you missing a using directive or an assembly reference?(CS0246)]

[Task:File=/home/awilliam/Works/DbLinq/dblinq2007-read-only/src/DbMetal/Configuration/ProvidersSection.cs, Line=41, Column=40, Type=Error, Priority=Normal, Description=The type or namespace name `ConfigurationElement' could not be found. Are you missing a using directive or an assembly reference?(CS0246)]

[Task:File=/home/awilliam/Works/DbLinq/dblinq2007-read-only/src/DbMetal/Configuration/ProvidersSection.cs, Line=62, Column=44, Type=Error, Priority=Normal, Description=The type or namespace name `ConfigurationElementCollection' could not be found. Are you missing a using directive or an assembly reference?(CS0246)]

mono-core-2.0.1-18.1.i586
monodevelop-1.9-1.3.noarch


Adam Tauno Williams

unread,
Dec 29, 2008, 10:40:04 AM12/29/08
to dbl...@googlegroups.com

Okay, there was a reference in the DbMetal project to
"System.configuration", once I removed that and added a reference to
"System.Configuration", it *almost* builds!

Now it just dies with -


[Task:File=, Line=0, Column=0, Type=Error, Priority=Normal,

Description=File
'/home/awilliam/Works/DbLinq/dblinq2007-read-only/src/DbMetal/bin/DbMetal.exe.mdb' not found]


[Task:File=, Line=0, Column=0, Type=Error, Priority=Normal,

Description=/tmp/tmp525d0308.tmp]

Pascal Craponne

unread,
Dec 29, 2008, 2:30:26 PM12/29/08
to dbl...@googlegroups.com
This file is probably the Mono debug information, and it is Mono specific. Can one of the Mono guys reading this message give a hand?

Pascal.

jabber/gtalk: pas...@jabber.fr
msn: pas...@craponne.org



Adam Tauno Williams

unread,
Dec 29, 2008, 2:34:04 PM12/29/08
to dbl...@googlegroups.com
On Mon, 2008-12-29 at 20:30 +0100, Pascal Craponne wrote:
> This file is probably the Mono debug information,

Think so, switching from Debug to Release reduces the error message to
just:


[Task:File=, Line=0, Column=0, Type=Error, Priority=Normal,

Description=/tmp/tmp249b9816.tmp]

> and it is Mono specific. Can one of the Mono guys reading this
> message give a hand?

> > Now it just dies with -

Adam Tauno Williams

unread,
Jan 1, 2009, 2:34:56 PM1/1/09
to dbl...@googlegroups.com
On Mon, 2008-12-29 at 14:34 -0500, Adam Tauno Williams wrote:
> On Mon, 2008-12-29 at 20:30 +0100, Pascal Craponne wrote:
> > This file is probably the Mono debug information,
>
> Think so, switching from Debug to Release reduces the error message to
> just:
> [Task:File=, Line=0, Column=0, Type=Error, Priority=Normal,
> Description=/tmp/tmp249b9816.tmp]

Got a thread over at
<http://lists.ximian.com/pipermail/monodevelop-list/2008-December/008757.html>

Adam Tauno Williams

unread,
Jan 14, 2009, 10:06:46 AM1/14/09
to dbl...@googlegroups.com
On Thu, 2009-01-01 at 14:34 -0500, Adam Tauno Williams wrote:
> On Mon, 2008-12-29 at 14:34 -0500, Adam Tauno Williams wrote:
> > On Mon, 2008-12-29 at 20:30 +0100, Pascal Craponne wrote:
> > > This file is probably the Mono debug information,
> > Think so, switching from Debug to Release reduces the error message to
> > just:
> > [Task:File=, Line=0, Column=0, Type=Error, Priority=Normal,
> > Description=/tmp/tmp249b9816.tmp]
> Got a thread over at
> <http://lists.ximian.com/pipermail/monodevelop-list/2008-December/008757.html>

Sadly, it still fails with the new Mono 2.2.

Exception caught by the compiler while compiling:
Block that caused the problem begin
at: /home/awilliam/Works/DbLinq/dblinq2007-read-only/src/DbMetal/Generator/Implementation/CodeTextGenerator/CodeGenerator.Class.cs(588,99):
Block being compiled:
[/home/awilliam/Works/DbLinq/dblinq2007-read-only/src/DbMetal/Generator/Implementation/CodeTextGenerator/CodeGenerator.Class.cs(588,104):,/home/awilliam/Works/DbLinq/dblinq2007-read-only/src/DbMetal/Generator/Implementation/CodeTextGenerator/CodeGenerator.Class.cs(588,118):]
System.Exception: Expression Mono.CSharp.LocalVariableReference did not
set its type after Resolve

Adam Tauno Williams

unread,
Feb 11, 2009, 9:25:51 AM2/11/09
to dbl...@googlegroups.com

Supposedly this has been fixed in trunk.
<https://bugzilla.novell.com/show_bug.cgi?id=447807>

Eugene Kotlyarov

unread,
Feb 11, 2009, 10:36:42 AM2/11/09
to dbl...@googlegroups.com
Adam Tauno Williams wrote:
>>>> Think so, switching from Debug to Release reduces the error message to
>>>> just:
>>>> [Task:File=, Line=0, Column=0, Type=Error, Priority=Normal,
>>>> Description=/tmp/tmp249b9816.tmp]
>>> Got a thread over at
>>> <http://lists.ximian.com/pipermail/monodevelop-list/2008-December/008757.html>
>> Sadly, it still fails with the new Mono 2.2.
>> Exception caught by the compiler while compiling:
>> Block that caused the problem begin
>> at: /home/awilliam/Works/DbLinq/dblinq2007-read-only/src/DbMetal/Generator/Implementation/CodeTextGenerator/CodeGenerator.Class.cs(588,99):
>> Block being compiled:
>> [/home/awilliam/Works/DbLinq/dblinq2007-read-only/src/DbMetal/Generator/Implementation/CodeTextGenerator/CodeGenerator.Class.cs(588,104):,/home/awilliam/Works/DbLinq/dblinq2007-read-only/src/DbMetal/Generator/Implementation/CodeTextGenerator/CodeGenerator.Class.cs(588,118):]
>> System.Exception: Expression Mono.CSharp.LocalVariableReference did not
>> set its type after Resolve
>
> Supposedly this has been fixed in trunk.
> <https://bugzilla.novell.com/show_bug.cgi?id=447807>
Yes it is fixed in 2.4 preview and in trunk, but in 2.4 there is a
regression from 2.2 that influences dblinq
https://bugzilla.novell.com/show_bug.cgi?id=472805

It actually happens in DataContext.cs

[Task:File=/home/ekot/prg/dblinq/dblinq2007-read-only/src/DbLinq/Data/Linq/DataContext.cs,
Line=485, Column=63, Type=Error, Priority=Normal, Description=The call is
ambiguous between the following methods or properties:
`System.Linq.Expressions.Extensions.IsNullable(this System.Type)' and
`DbLinq.Util.TypeExtensions.IsNullable(this System.Type)'(CS0121)]

Pascal Craponne

unread,
Mar 28, 2009, 4:44:38 AM3/28/09
to dbl...@googlegroups.com
Hi Eugene, 

do you still get this problem?

Pascal.

jabber/gtalk: pas...@jabber.fr
msn: pas...@craponne.org



Eugene Kotlyarov

unread,
Mar 29, 2009, 4:32:25 AM3/29/09
to dbl...@googlegroups.com
Hi

Pascal Craponne wrote:
>
> do you still get this problem?
>

No they fixed it.
There appeared another problem though


/home/ekot/prg/dblinq2007/src/DbLinq/Test/Providers/Linq_101_Samples/Count_Sum_Min_Max_Avg.cs(240,67):
error CS0019: Operator `>' cannot be applied to operands of type `decimal?'
and `double'
/home/ekot/prg/dblinq2007/src/DbLinq/Test/Providers/Linq_101_Samples/Count_Sum_Min_Max_Avg.cs(245,35):
error CS0411: The type arguments for method
`System.Linq.Enumerable.ToList<TSource>(this
System.Collections.Generic.IEnumerable<TSource>)' cannot be inferred from
the usage. Try specifying the type arguments explicitly
/home/ekot/prg/dblinq2007/src/DbLinq/Test/Providers/Linq_101_Samples/Count_Sum_Min_Max_Avg.cs(246,32):
error CS0019: Operator `>' cannot be applied to operands of type `method
group' and `int'


Pascal Craponne

unread,
Mar 29, 2009, 5:34:53 AM3/29/09
to dbl...@googlegroups.com
This looks like a Mono problem and I suggest:
- submit it to mono
- make a small patch for dblinq until the problem is fixed (the small patch consisting in using intermediate variables)

Pascal.

jabber/gtalk: pas...@jabber.fr
msn: pas...@craponne.org



Jonathan Pryor

unread,
Mar 29, 2009, 9:44:52 AM3/29/09
to dbl...@googlegroups.com
On Sun, 2009-03-29 at 12:32 +0400, Eugene Kotlyarov wrote:
> /home/ekot/prg/dblinq2007/src/DbLinq/Test/Providers/Linq_101_Samples/Count_Sum_Min_Max_Avg.cs(240,67):
> error CS0019: Operator `>' cannot be applied to operands of type `decimal?'
> and `double'

This has been filed and fixed:

https://bugzilla.novell.com/show_bug.cgi?id=482996

Alas, it was fixed in trunk, after Mono 2.4 was branched. So you'll
either need to wait for Mono 2.6, or build Mono from trunk; see:

http://www.mono-project.com/Parallel_Mono_Environments

- Jon


Reply all
Reply to author
Forward
0 new messages