1. Pierre Couvreur
  2. SnapDevelop
  3. Tuesday, 12 January 2021 09:32 AM UTC

Hello all,

I'm new to snapdevelop.

Everything works fine except when the converted dataWindow is not updatable, even if the only method is "RetrieveByKey" in both the controler and the service. I'm using an Oracle connection. 

Here is the web API Tester error message :

http://localhost:5000/api/Cantonnements/RetrieveOne/952

An unhandled exception occurred while processing the request.

NotSupportedException: The method does not support non-updatable datawindow

DWNet.Data.AdoDataSource<TModel>.CanUseRetrieveByKey()

 

Is this a known limitation or am I'm missing something ?

Thank you,

Pierre

 

Govinda Lopez @Appeon Accepted Answer Pending Moderation
  1. Tuesday, 12 January 2021 16:21 PM UTC
  2. SnapDevelop
  3. # 1

Hi Pierre,

 

Have you tried adding the [Key] token to your .NET DataStore? (See the [Key] token added to the Primary Key column in the following example)

 

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using SnapObjects.Data;
using DWNet.Data;
using Newtonsoft.Json;

namespace Appeon.ApiDoc.Models
{
    [DataWindow("d_department", DwStyle.Grid)]
    [Table("Department", Schema = "dbo")]
    #region DwSelectAttribute  
    [DwSelect("PBSELECT( VERSION(400) TABLE(NAME=\"Department\" ) @(_COLUMNS_PLACEHOLDER_) )")]
    #endregion
    [UpdateWhereStrategy(UpdateWhereStrategy.KeyAndConcurrencyCheckColumns)]
    [DwKeyModificationStrategy(UpdateSqlStrategy.DeleteThenInsert)]
    [DwTemplate(DataFormat.Xml, "xml_default", "Templates\\xml_setparameter_default.xml", IsDefault = true)]
    public class D_Department
    {
        [Key]
        [DwColumn("Department", "DepartmentID")]
        public int Departmentid { get; set; }

        [ConcurrencyCheck]
        [DwColumn("Department", "Name")]
        public string Name { get; set; }

        [ConcurrencyCheck]
        [DwColumn("Department", "Budget")]
        public decimal Budget { get; set; }

        [ConcurrencyCheck]
        [DwColumn("Department", "StartDate")]
        public DateTime Startdate { get; set; }

        [ConcurrencyCheck]
        [DwColumn("Department", "Administrator")]
        public int? Administrator { get; set; }

    }

}

 

Regards,

Comment
  1. Armeen Mazda @Appeon
  2. Tuesday, 12 January 2021 17:13 PM UTC
Hi Logan, Is there a bug with the DataWindow Converter? Pierre did not create this model by hand... the model was automatically created by DataWindow Converter.
  1. Helpful
  1. Logan Liu @Appeon
  2. Wednesday, 13 January 2021 07:28 AM UTC
Hi Armeen,

This is not a bug with the DataWindow Converter.

This is the limitation of the RetrieveByKey method of .NET DataStore This RetrieveByKey method is not existing in PowerBuilder. It is designed to reuse the key and table defined in the model to build a simple SQL Select statement to only retrieve data by key.

For a non-updatable DataWindow, we don't know which is the updatable table and its key from the DataWindow syntax, so we can't generate [Table] and [Key] attributes. Pierre can add [Key] and [Table] attributes by hand. Or modify this DataWindow to make it updateable in PowerBuilder, then convert .NET DataStore model again.

Regards, Logan
  1. Helpful
  1. Pierre Couvreur
  2. Wednesday, 13 January 2021 07:58 AM UTC
Hi Logan,



Your explanations are very clear, thank you.



In my example, I should have used the Retrieve() method instead of RetrieveByKey().



Thanks a lot.

Pierre

  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.