1. paulo gomes
  2. SnapObjects
  3. Thursday, 8 August 2019 01:58 AM UTC

Hi All,

We are migrating a NVO to REST C# Web API. One of the methods that has to be migrated gets as argument a datastore and return, by reference, two (02) string arrays: column_names and dataTypes_names

The PB method get the number of datastore columns and then loop to get the column names and data-types, using the datastore.Describe whithin the loop.

The DataStore object is one of the Snap Develop in the collection IDataStore, if I'm not wrong. It has almost all methods we find in a PB datastore and other methods and properties that belong only to the .Net framework and that does not exist in PB. 

However, I could not find my way in Snap Develop to get the number of columns in a datastore and get their names and the corresponding data-types.

Is it possible with the actual Snap Develop version? I already know that Describe seems to be missing.

Thank you,

Paulo Gomes

Interval International

pgomes@intervalintl.com

 

 

Who is viewing this page
paulo gomes Accepted Answer Pending Moderation
  1. Thursday, 8 August 2019 14:33 PM UTC
  2. SnapObjects
  3. # 1

Hi Logan,

Great !

 

I'll try these and will contact you if I have other issues.

Thank you for the reply.

 

PAULO GOMES

Senior System Analyst / Programmer, Interval International - Since October 2007

Resort Solution Development IT Team

6262 Sunset Drive • Miami, Florida 33143

Phones: 305.666.1861, ext. 7393 • direct 305.925.7393   Fax:305.668.3409

 

 

Comment
There are no comments made yet.
Logan Liu Accepted Answer Pending Moderation
  1. Thursday, 8 August 2019 09:47 AM UTC
  2. SnapObjects
  3. # 2

Hi Paulo,

You can get PB DataWindow datatypes parsed from .srd:

string[] columnNames = dataStore.Object.DataWindow.Table.Columns.Select(o => o.Name).ToArray();

//PB DataTypes
string[] pbDataTypes = dataStore.Object.DataWindow.Table.Columns.Select(o => o.Type).ToArray();

or access properties of the Model directly:

// Get the type of the Model, then get its properties.
var properties = dataStore.Object.ModelType.GetProperties();
string[] columnNames = properties.Select(o => o.Name).ToArray();

// Get types of the properties.
var clrDataTypes = properties.Select(o => o.PropertyType).ToArray(); 

BTW:

There is a known issue about the ClrType property (such as: DataWindow.Table.Columns[0].ClrType). It is parsed from DataWindow datatypes. and it may be different with the real properties of the Model.

// When this known issue is fixed, you will be able to get CLR datatypes like this as well:
string[] clrDataTypes = dataStore.Object.DataWindow.Table.Columns.Select(o => o.ClrType).ToArray();

Regards,

Logan

Comment
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.