SolutionsDesign / LLBLGenProSybaseASA

Sybase iAnywhere (ASA) Driver and DQE for LLBLGen Pro v5.0
MIT License
1 stars 3 forks source link

Wrong templates? #2

Open bulldetektor opened 6 years ago

bulldetektor commented 6 years ago

It seems that the SybaseASE templates are included in this repo and not the ASA templates;

https://github.com/SolutionsDesign/LLBLGenProSybaseASA/blob/master/Templates/SD.TemplateBindings.SybaseAseSpecific.templatebindings

FransBouma commented 6 years ago

aha! I think that's also the cause of the problem you had in #1, where the template you need isn't found as the paths are wrong. We'll correct this.

FransBouma commented 6 years ago

Should be fixed with https://github.com/SolutionsDesign/LLBLGenProSybaseASA/commit/6a345ca0b3166b6ae6cb2886b13eec9ba6553dff

FransBouma commented 6 years ago

So in short: just download the templatebindings file and adjust it for the .net versions you're using, and replace the ase templatebindings file in the Templates folder with the new one for ASA. The asa template bindings file has references to the right stored procedure include template so the problem with #1 should be fixed with this as well.

bulldetektor commented 6 years ago

Yes, I managed to do this, and I got all the templates loaded (I think). But now I get the infamous "Unable to find the requested .Net Framework Data Provider. It may not be installed.". The SQLAnywhere is registered in machine.config;


 <DbProviderFactories>
      <add name="SQL Anywhere 17 Data Provider" invariant="Sap.Data.SQLAnywhere" description=".NET Framework Data Provider for SQL Anywhere 17" type="Sap.Data.SQLAnywhere.SAFactory, Sap.Data.SQLAnywhere.EF6, Version=17.0.9.48034, Culture=neutral, PublicKeyToken=f222fc4333e0d400" />
    </DbProviderFactories>

But I just can't figure out where the link betwen the SybaseASADbDriver (that I now has compiled for LLBLGen 5.4) and the actual driver is? Is there some config somewhere that I have missed? There's no reference to SQLAnywhere in the driver project nor in the llblgenproj file. So how does LLBLGen know which Ado.Net driver (and version of the driver) to use?

bulldetektor commented 6 years ago

Btw; I can send you a pull request on the changes I made to get the driver up and running against 5.4 and SybaseASA.

FransBouma commented 6 years ago

The driver is obtained from the machine.config indeed, indirectly, through DbProviderFactories.GetFactory(). This is done in the driver and the DQE. The driver uses the name as returned by this property: https://github.com/SolutionsDesign/LLBLGenProSybaseASA/blob/master/Driver/SybaseAsaDBDriver.cs#L678 and the DQE uses the name as defined here: https://github.com/SolutionsDesign/LLBLGenProSybaseASA/blob/master/DynamicQueryEngine/DynamicQueryEngine.cs#L75

The name that matters is the 'invariant' name. As you can see, they're using the old name before SAP introduced the branding into the namespaces. So you should change iAnywhere.Data.SQLAnywhere into Sap.Data.SQLAnywhere. In the DQE on the line 75 I specified above, it also defines the enum type with the parameter types (iAnywhere.Data.SQLAnywhere.SADbType). I think that should be changed to 'Sap.Data.SQLAnywhere.SADbType' too.

After that the driver (and dqe) will pass the new name 'Sap.Data.SQLAnywhere' to DbProviderFactories.GetFactory() and will get the proper factory instance back.

Both the driver and DQE support multiple definitions btw, so if your code has to support both the old iAnywhere based ado.net provider and the newer Sap one, you can do so: please see the MySQL Driver and DQE for examples. I think that's about it. If not, please let me know :)

Regarding a PR, sure that would be great, thanks :)

bulldetektor commented 6 years ago

Thanks! Just made a pull request for the v 5.4 stuff, but will make another one when I've done the changes for SQLAnywhere 17.

bulldetektor commented 6 years ago

Btw; If I make these changes it would probably mean that you should branch out to a 'SQLAnyhwere 17' - or maybe a separate repo. Can't see how these changes could work against both SQLAnywhere 16 and below and from 17 and above in the same codebase...

bulldetektor commented 6 years ago

Where exactly do I find the examples for MySQL? Is it the driver.config for the MySQL you have in mind?

FransBouma commented 6 years ago

Btw; If I make these changes it would probably mean that you should branch out to a 'SQLAnyhwere 17' - or maybe a separate repo. Can't see how these changes could work against both SQLAnywhere 16 and below and from 17 and above in the same codebase...

I am not familiar with the differences, is the difference only in ADO.NET provider name? Then it can be done. For the driver, just add the Sap.Data.SQLAnywhere string to this line instead of replacing it: https://github.com/SolutionsDesign/LLBLGenProSybaseASA/blob/master/Driver/SybaseAsaDBDriver.cs#L678. The designer will then load the first ADO.NET provider which has a factory registered. For the DQE, it has to register two factories/types. This line: https://github.com/SolutionsDesign/LLBLGenProSybaseASA/blob/master/DynamicQueryEngine/DynamicQueryEngine.cs#L75

should be replaced with:

SybaseAsaSpecificCreator.SetDbProviderFactoryParameterData(new List<ValuePair<string, string>>()
    { 
        new ValuePair<string, string>("iAnywhere.Data.SQLAnywhere", "iAnywhere.Data.SQLAnywhere.SADbType"),
        new ValuePair<string, string>("Sap.Data.SQLAnywhere", "iAnywhere.Data.SQLAnywhere.SADbType")
    }, "SADbType");

And this method: https://github.com/SolutionsDesign/LLBLGenProSybaseASA/blob/master/DynamicQueryEngine/SybaseAsaSpecificCreator.cs#L71

should be replaced with:

public static void SetDbProviderFactoryParameterData(List<ValuePair<string, string>> dbProviderFactoryInvariantNamesAndEnumTypeNames, 
                                                     string dbProviderSpecificEnumTypePropertyName)
{
    _dbProviderFactoryInfo.SetDbProviderFactoryParameterData(dbProviderFactoryInvariantNamesAndEnumTypeNames, dbProviderSpecificEnumTypePropertyName);
}

Then again the DQE will pick up the first ado.net provider that's installed, either the old iAnywhere one or the new Sap one.

The example for MySQL is in the sourcecode archive on the website under My account ->Downloads -> version -> Extras section. We had support for CoreLab and DevArt for MySql for a long time (same company, newer name was 'DevArt'), the v5.4 code drops the Corelab name so I have used v4.2's sourcecode above to help you with this.

As for the PR, we can't test it as Sap doesn't give us a dev license anymore for their databases hence we dropped support for Sybase (and put the source here for the people who need it). I'll create a iAnywhere branch just in case for the few who need that older code before merging.