Problem on Rendering of Datatable GetMultiAsDataTable method in LLBLGen v5.9.1

Posts   
 
    
bimar
User
Posts: 12
Joined: 17-Oct-2017
# Posted on: 08-Jun-2022 09:57:08   

Hi,

Fyi: Using LLBLGen v5.9.1, generated target fw is net standard and database Oracle12C, also TypeConverter version is 5.9.1

We encountered an issue in version 5.9.1 that confuses us. Before the data extraction process (GetMultiAsDataTable), we fill in the column names ourselves as you can see below the data table where the data will be transferred. When the following code runs, the value we want to pull to the datatable is empty.

// Failed  version
{
  // setup the field
  ResultsetFieldCollection newCollection = new ResultsetFieldCollection();
  newCollection.Add(DhMuhSirketiKumpanyaFields.HizmtBrlkteFatKntrEdlckMi, "HizmetlerinBirlikteFatKontrolEdilecekMi");

  DataTable dynamicList = new DataTable("resultingDataTable");
  ResultsetFields _resultSet = new ResultsetFields(1);

  _resultSet[0] = newCollection[0];
  string dataColumnName = (newCollection[0].Alias.Equals("")) ? newCollection[0].Name : newCollection[0].Alias;
  DataColumn dc = null;
  if (newCollection[0].DataType != null) {
    Type dataColumnType = getNotNullableType(newCollection[0].DataType);
    dc = new DataColumn(dataColumnName, dataColumnType);
    if (dataColumnType.Equals(typeof (String))) dc.MaxLength = newCollection[0].MaxLength;
  } else {
    dc = new DataColumn(dataColumnName, typeof (string));
  }
  dynamicList.Columns.Add(dc);

  IPredicateExpression filtre = new PredicateExpression();
  filtre.Add(DhMuhSirketiKumpanyaFields.Id == 101);

  // fetch results
  TypedListDAO dao = new TypedListDAO();
  dao.GetMultiAsDataTable(_resultSet, dynamicList, 0, null, filtre, null, false, null, null, 0, 0);
}

When the following code runs, the datatable is created properly. And we can see the value in it.

// Working version
{
  // setup the field
  ResultsetFields fields = new ResultsetFields(1);
  fields.DefineField(DhMuhSirketiKumpanyaFields.HizmtBrlkteFatKntrEdlckMi, 0, "HizmetlerinBirlikteFatKontrolEdilecekMi");

  IPredicateExpression filtre = new PredicateExpression();
  filtre.Add(DhMuhSirketiKumpanyaFields.Id == 101);

  // fetch results
  DataTable dynamicList = new DataTable("resultingDataTable");
  TypedListDAO dao = new TypedListDAO();
  dao.GetMultiAsDataTable(fields, dynamicList, 0, null, filtre, null, false, null, null, 0, 0);
}

You can also examine the working and failing version datatable images in the attached screenshot.

I would like your help in figuring out what is the problem is here.

Thanks.

Attachments
Filename File size Added on Approval
DataTableRendering.PNG 33,528 08-Jun-2022 09:57.55 Approved
bimar
User
Posts: 12
Joined: 17-Oct-2017
# Posted on: 09-Jun-2022 08:03:28   

Dear Support Team,

Our Customer Id: 19501

We're think that this issue is a bug, because same code (on below) block works in version 5.5 but not in v5.9.1. And it's so urgent for us we noticed this error on live system.

// Failed  version
{
  // setup the field
  ResultsetFieldCollection newCollection = new ResultsetFieldCollection();
  newCollection.Add(DhMuhSirketiKumpanyaFields.HizmtBrlkteFatKntrEdlckMi, "HizmetlerinBirlikteFatKontrolEdilecekMi");

  DataTable dynamicList = new DataTable("resultingDataTable");
  ResultsetFields _resultSet = new ResultsetFields(1);

  _resultSet[0] = newCollection[0];
  string dataColumnName = (newCollection[0].Alias.Equals("")) ? newCollection[0].Name : newCollection[0].Alias;
  DataColumn dc = null;
  if (newCollection[0].DataType != null) {
    Type dataColumnType = getNotNullableType(newCollection[0].DataType);
    dc = new DataColumn(dataColumnName, dataColumnType);
    if (dataColumnType.Equals(typeof (String))) dc.MaxLength = newCollection[0].MaxLength;
  } else {
    dc = new DataColumn(dataColumnName, typeof (string));
  }
  dynamicList.Columns.Add(dc);

  IPredicateExpression filtre = new PredicateExpression();
  filtre.Add(DhMuhSirketiKumpanyaFields.Id == 101);

  // fetch results
  TypedListDAO dao = new TypedListDAO();
  dao.GetMultiAsDataTable(_resultSet, dynamicList, 0, null, filtre, null, false, null, null, 0, 0);
}

I ask for your support, thanks.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39588
Joined: 17-Aug-2003
# Posted on: 09-Jun-2022 08:41:48   

We'll look into it

I think it's because the name you specify as an alias is considered 'too long' (it's 40 characters) and therefore is re-aliased. The resultset coming from the database therefore has the F_someNumber alias for the field, which isn't present in the datatable and therefore it's skipped.

However I do recall we did something about this, as recent Oracle versions don't need the clamping anymore. We'll check it out.

(so a workaround for now is that you use a column name that has less than 30 characters)

Frans Bouma | Lead developer LLBLGen Pro
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39588
Joined: 17-Aug-2003
# Posted on: 09-Jun-2022 09:16:03   

Please see this thread for a discussion about this issue: https://www.llblgen.com/tinyforum/Thread/27269. In short: we removed the clamping on fields on tables, as these are compatible with the database they're made for anyway, but for aliases we kept it. It's precisely the alias clamping you run into (as you specify an alias that's 40+ characters long).

As we assumed the issue 'solved' with our changes in 5.7/5.8 as described in the above thread, we didn't introduce a new compatibility level specifically for aliases for this, as in general one doesn't really notice this (except for the situation where you create the columns yourself and specify an alias that's 40 characters long, as you have found out).

So, to fix this, the easiest for you is to use an alias name that's 30 characters or shorter, so in the line:

newCollection.Add(DhMuhSirketiKumpanyaFields.HizmtBrlkteFatKntrEdlckMi, "HizmetlerinBirlikteFatKontrolEdilecekMi");

The DataTableColumn class has a Caption field btw, which you can use for a longer name to use in e.g. GUIs and databinding scenarios. The name doesn't need to be the same (and in your case can be shorter).

Another workaround is given in the thread above, but that requires you to change a line of code in the runtime.

Frans Bouma | Lead developer LLBLGen Pro
bimar
User
Posts: 12
Joined: 17-Oct-2017
# Posted on: 09-Jun-2022 09:17:07   

Hi Otis,

Thanks for reply and support. But unfortunately, we cannot proceed as a workaround (using column name less than 30 char) because we can't detect how much usage is in this way in code base. We can change one place and continue, but we can still get an error in a different place. So we'll have to wait for your review to finish.

Best regards.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39588
Joined: 17-Aug-2003
# Posted on: 09-Jun-2022 17:09:47   

bimar wrote:

Hi Otis,

Thanks for reply and support. But unfortunately, we cannot proceed as a workaround (using column name less than 30 char) because we can't detect how much usage is in this way in code base. We can change one place and continue, but we can still get an error in a different place. So we'll have to wait for your review to finish. Best regards.

Not sure I understand what you're saying simple_smile We're not reviewing anything as there's nothing we can do other than introduce a new compatibility level which we'll do only in new versions, and it would come down to only being used for the alias length, something users normally don't run into, unless they specifically specify an alias themselves which is longer than 30 characters. The other thing we could do is add another static configuration flag to the DynamicQueryEngine, but we don't like adding these in point releases.

The other way you can work around it is by changing the line which creates the OracleSpecificCreator and pass false to the constructor. As you're already compiling your own runtime if I recall correctly, it shouldn't be a lot of work for you to do that, see the thread I linked to above.

The 'error in a different place' is that the same issue? As in: you have a column name that's > 30 characters?

Frans Bouma | Lead developer LLBLGen Pro
bimar
User
Posts: 12
Joined: 17-Oct-2017
# Posted on: 13-Jun-2022 10:19:28   

We decided to move forward by reducing the number of characters on alias (If the number of characters exceeds 30).

Thanks for your usual support Otis simple_smile

Best regards.