How to develop database drivers?

Posts   
1  /  2
 
    
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39619
Joined: 17-Aug-2003
# Posted on: 27-Mar-2006 12:00:18   

Rushmore wrote:

Hi Otis,

I think, I have a workaround for that:

Reading the "TABLE" meta data aren´t the problem. That gives me the idea, to read the "COLUMN" meta data for each table separately. And miraculously - that method reads all the columns (more than 11.000) without an exception.

Now I have to modify the Golden(Schema)Retriever smile haha.

hehe simple_smile . That's indeed a way to do it simple_smile It might take a little longer, but not much I think. How the meta-data is read is totally up to the driver, so if you need per-table column metadata reads, you can do it. simple_smile

Frans Bouma | Lead developer LLBLGen Pro
Rushmore
User
Posts: 125
Joined: 27-Jan-2005
# Posted on: 27-Mar-2006 18:20:10   

Hi Otis,

I think I have to work on the relation stuff. After I have modified the CatalogRetriever source:

// I don´t know why foreignKeyField is sometimes null // CB/27.03.2006 if (foreignKeyField != null) { foreignKeyField.IsForeignKey = true; newForeignKeyConstraint.ForeignKeyFields.Add(foreignKeyField); }

// I don´t know why primaryKeyField is somtimes null // CB/27.03.2006 if (primaryKeyField != null) newForeignKeyConstraint.PrimaryKeyFields.Add(primaryKeyField);

the database schema is read without an exception, and I can generate the DAL sunglasses . But the most (not all) relations are lost confused frowning .

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39619
Joined: 17-Aug-2003
# Posted on: 28-Mar-2006 11:42:10   

It can be the fields / tables aren't found because the FK is defined on a field 'foo' and the field in the table is called Foo.

Frans Bouma | Lead developer LLBLGen Pro
Rushmore
User
Posts: 125
Joined: 27-Jan-2005
# Posted on: 29-Mar-2006 08:46:30   

Ok,

I will do my first test to switch from one DBMS to another (ex. Sql Server 2005 to Foxpro) at Runtime.

Both db´s have the same structure and namespace.

Is there any tutorial out there?

Regards, Carlo

P.S. I take a look at the relation stuff later wink

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39619
Joined: 17-Aug-2003
# Posted on: 29-Mar-2006 09:27:54   

Tutorial for what exactly? Using 2 different dbs in one app? -> adapter, create a small factory for DataAccessAdapter instances, and program against IDataAccessAdapter simple_smile

Frans Bouma | Lead developer LLBLGen Pro
Rushmore
User
Posts: 125
Joined: 27-Jan-2005
# Posted on: 29-Mar-2006 17:38:01   

Tutorial for what exactly?

adapter, create a small factory for DataAccessAdapter instances, and program against IDataAccessAdapter. That´s it wink !

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39619
Joined: 17-Aug-2003
# Posted on: 30-Mar-2006 11:02:54   

If you want, I can setup a Folder for you in our subversion repository at svn: //www.sd.nl/LLBLGenPro

Frans Bouma | Lead developer LLBLGen Pro
arschr
User
Posts: 893
Joined: 14-Dec-2003
# Posted on: 30-Mar-2006 15:19:51   

I would love to have access to Foxpro drivers!

Rushmore
User
Posts: 125
Joined: 27-Jan-2005
# Posted on: 31-Mar-2006 09:34:57   

If you want, I can setup a Folder for you in our subversion repository at svn: //www.sd.nl/LLBLGenPro

That would be very nice. How can I access the repository?

I would love to have access to Foxpro drivers!

The work isn´t completed. There are some known issues I have to work on disappointed . And I think a lot of unknown issues frowning

But for simple database access (select, insert, update, delete) it works very well sunglasses . You must generate your own primary key value (surrogate key or whatever) cry .

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39619
Joined: 17-Aug-2003
# Posted on: 31-Mar-2006 10:39:36   

Rushmore wrote:

If you want, I can setup a Folder for you in our subversion repository at svn: //www.sd.nl/LLBLGenPro

That would be very nice. How can I access the repository?

Please email the username and password of your choice to support AT llblgen.com and I'll add you to the users who have write access.

You can access the repository by installing subversion and tortoisesvn. Please go to: http://subversion.tigris.org for details. The repository is located at:

svn://www.sd.nl/LLBLGenPro
Frans Bouma | Lead developer LLBLGen Pro
Rushmore
User
Posts: 125
Joined: 27-Jan-2005
# Posted on: 03-Apr-2006 14:03:56   

Hi Otis,

I have uploaded the binaries and sources to the repository.

Today a run into a new problem:

that one works very well: EntityCollection klienten = new EntityCollection(new KlientEntityFactory()); IPrefetchPath2 prefetch = new PrefetchPath2((int)EntityType.KlientEntity); prefetch.Add(KlientEntity.PrefetchPathAdressen);

adapter.FetchEntityCollection(klienten, null, prefetch);

that one don´t EntityCollection klienten = new EntityCollection(new KlientEntityFactory()); IRelationPredicateBucket relations = new RelationPredicateBucket(); relations.Relations.Add(KlientEntity.Relations.AdressenEntityUsingXadrId, JoinHint.Inner);

adapter.FetchEntityCollection(klienten, relations, null);

Operation is invalid for a Memo, Blob, General or Picture field.. Check InnerException, QueryExecuted and Parameters of this exception to examine the cause of this exception.

The generated query runs without any problems in VFP. confused

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39619
Joined: 17-Aug-2003
# Posted on: 03-Apr-2006 14:33:10   

Probably 'DISTINCT' which is in the query but not possible if a field of one of those types is present. Please check the Sqlserver DQE sourcecode for the selectdq how to filter on those types.

Frans Bouma | Lead developer LLBLGen Pro
Rushmore
User
Posts: 125
Joined: 27-Jan-2005
# Posted on: 03-Apr-2006 16:02:04   
Probably 'DISTINCT' which is in the query but not possible if a field of one of those types is present.

Yeeah, that´s it. simple_smile

distinctViolatingTypesFound |= (((OleDbType)fieldsPersistenceInfo[i].SourceColumnDbType == OleDbType.VarWChar) || ((OleDbType)fieldsPersistenceInfo[i].SourceColumnDbType == OleDbType.Binary));

VarWChar instead of LongVarWChar and Binary instead of LongVarbinary

Rushmore
User
Posts: 125
Joined: 27-Jan-2005
# Posted on: 04-Apr-2006 11:33:14   

Hi Otis,

do you have a method which generates a 20 byte alphanumeric unique key?

Regards, Carlo

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39619
Joined: 17-Aug-2003
# Posted on: 04-Apr-2006 12:30:13   

Rushmore wrote:

Hi Otis,

do you have a method which generates a 20 byte alphanumeric unique key?

Regards, Carlo

No, though you can use a guid and use its 16 unique bytes and fill it up with 0's simple_smile A guid is somewhat guaranteed to be unique.

Be aware that a guid isn't sequential, so it slows down clustered indexes (sorted indexes on disk).

Frans Bouma | Lead developer LLBLGen Pro
Rushmore
User
Posts: 125
Joined: 27-Jan-2005
# Posted on: 14-Apr-2006 02:48:45   

Hi Otis,

I can´t use the 16 byte guid because foxpro don´t like values less than 0x20h in fields who are index.

BTW

this message is only to keep you up to date. The most methods are work perfectly for me.

I haven´t take care about the relations (SchemaRetriever), but the relations are defined in the LLBLGEN UI very fast.

I Have generated the DAL (Foxpro) for a WebService who handles the data access and buisness logic. Then I have generated (from the same LLBLGEN Project) the DAL for the CompactFramework.

And what? After a little (and more) reasearch about sessions on a ppc (cf) everything works fine. But it is very pitty, that I must modify the reference.cs file because of the "System.Data.DataSet" shit - you know! I have already read about the third party template.

The goal? It is really simple to work with the generated code. I have spend a lot of time for the FoxproDriver and for the FoxproDQE but for all VFP Developers - LLBLGEN isn´t only a OR/M it is pure fun too.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39619
Joined: 17-Aug-2003
# Posted on: 15-Apr-2006 09:55:42   

Rushmore wrote:

Hi Otis,

I can´t use the 16 byte guid because foxpro don´t like values less than 0x20h in fields who are index. BTW

this message is only to keep you up to date. The most methods are work perfectly for me.

Cool! simple_smile

I haven´t take care about the relations (SchemaRetriever), but the relations are defined in the LLBLGEN UI very fast.

If you can pull out the FK's from foxpro you can order the base class of the catalogretriever to produce the relations for you. simple_smile

I Have generated the DAL (Foxpro) for a WebService who handles the data access and buisness logic. Then I have generated (from the same LLBLGEN Project) the DAL for the CompactFramework.

And what? After a little (and more) reasearch about sessions on a ppc (cf) everything works fine. But it is very pitty, that I must modify the reference.cs file because of the "System.Data.DataSet" shit - you know! I have already read about the third party template.

I don't remember that I ran into that particular issue... I didn't need any special template for SqlServerCE, could you elaborate a bit where this issue pops up?

The goal? It is really simple to work with the generated code. I have spend a lot of time for the FoxproDriver and for the FoxproDQE but for all VFP Developers - LLBLGEN isn´t only a OR/M it is pure fun too.

smile

Question: you wrote a driver for an older version of foxpro, correct? Is it usable on newer versions like foxpro 7, 8 or doesn't it support features which are available in those dbs?

Frans Bouma | Lead developer LLBLGen Pro
Rushmore
User
Posts: 125
Joined: 27-Jan-2005
# Posted on: 18-Apr-2006 12:31:45   

Question: you wrote a driver for an older version of foxpro, correct?

No, that isn´t correct. The driver doesn´t work for free tables (I will work on that!). That means, you can use the driver for Visual Foxpro 3 and above (currently VFP 9) using a database container (DBC file).

If you can pull out the FK's from foxpro you can order the base class of the catalogretriever to produce the relations for you.

I will give it a try simple_smile

I don't remember that I ran into that particular issue... I didn't need any special template for SqlServerCE, could you elaborate a bit where this issue pops up?

Ok, look here:

  • 1. Build a webservice

[WebMethod(true)] public EntityCollection GetCustomers() { // some code and return EntityCollection }

  • Publish the webservice.

  • Add the webservice reference to the client.

  • Use the generated (webservice wrapper) code.

The GetCustomers()-Method returns a DataSet instead of a EntityCollection. And that´s the point. The reference.cs file must be modified manually so that the right datatype is returned (in the example, EntityCollection). And that is why I have talked about a third party template.

What about LLBLgen V2? Any beta available?

Regards, Carlo

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39619
Joined: 17-Aug-2003
# Posted on: 19-Apr-2006 11:34:18   

Rushmore wrote:

Question: you wrote a driver for an older version of foxpro, correct?

No, that isn´t correct. The driver doesn´t work for free tables (I will work on that!). That means, you can use the driver for Visual Foxpro 3 and above (currently VFP 9) using a database container (DBC file).

I'm a complete foxpro n00b so I have no idea what free tables are but I like the idea that it works with all foxpro versions! simple_smile

I don't remember that I ran into that particular issue... I didn't need any special template for SqlServerCE, could you elaborate a bit where this issue pops up?

Ok, look here:

  • 1. Build a webservice

[WebMethod(true)] public EntityCollection GetCustomers() { // some code and return EntityCollection }

  • Publish the webservice.

  • Add the webservice reference to the client.

  • Use the generated (webservice wrapper) code.

The GetCustomers()-Method returns a DataSet instead of a EntityCollection. And that´s the point. The reference.cs file must be modified manually so that the right datatype is returned (in the example, EntityCollection). And that is why I have talked about a third party template.

Oh that issue, yes that's a known issue with .NET 1.x and webservices: wsdl.exe always assumes you'll return a datatable when IXmlSerializable is implemented on the object... This is somewhat solved in .NET 2.0, however not that good. For .NET 2.0 there are templates available in the 3rd party section.

What about LLBLgen V2? Any beta available?

As a customer you'll get notified through the website and this forum when beta starts simple_smile I hope to have beta bits next week simple_smile

Frans Bouma | Lead developer LLBLGen Pro
Rushmore
User
Posts: 125
Joined: 27-Jan-2005
# Posted on: 20-Apr-2006 13:07:31   

... I have no idea what free tables are

Since VFP 3, M$ has build a datadictionary (called database container) for the free tables (dbf files) and suddenly it is a little bit like a database.

Free tables are not married with the database container (dbc file). If a table belongs to a dbc, the dbc name/path or whatever is stored in the header of the table (dbf file).

using free tables: ConnectionString = @"Provider=VFPOLEDB.1;Data Source=\Data"

using the database container ConnectionString = @"Provider=VFPOLEDB.1;Data Source=\Data\Database.dbc"

I will put an option box into the foxpro driver user interface with two options:

  1. Free tables
  2. DBC

Regards, Carlo

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39619
Joined: 17-Aug-2003
# Posted on: 22-Apr-2006 11:33:01   

Rushmore wrote:

... I have no idea what free tables are

Since VFP 3, M$ has build a datadictionary (called database container) for the free tables (dbf files) and suddenly it is a little bit like a database.

Free tables are not married with the database container (dbc file). If a table belongs to a dbc, the dbc name/path or whatever is stored in the header of the table (dbf file).

using free tables: ConnectionString = @"Provider=VFPOLEDB.1;Data Source=\Data"

using the database container ConnectionString = @"Provider=VFPOLEDB.1;Data Source=\Data\Database.dbc"

I will put an option box into the foxpro driver user interface with two options:

  1. Free tables
  2. DBC

Ah, thanks for the heads up! simple_smile Keep up the good work! simple_smile

Frans Bouma | Lead developer LLBLGen Pro
1  /  2