Hi,

       I use EntitySchemaQuery to get Entity, but I can't get primary key value of result entity. The exception said: not found "Id" (something likes this)

EntitySchemaQuery esqDetails = new EntitySchemaQuery(UserConnection.EntitySchemaManager, "UsrExportDetails");

            esqDetails.AddColumn("Id");

            esqDetails.AddColumn("UsrCodeLevel1");

            esqDetails.Filters.Add(esqDetails.CreateFilterWithParameters(FilterComparisonType.Equal, "UsrExport", id));

            var exportDetails = esqDetails.GetEntityCollection(UserConnection);

            

            foreach    (var details in exportDetails)

            {

                var refId = details.GetTypedColumnValue("Id");

                var qrCodeRefId = details.GetTypedColumnValue("UsrCodeLevel1Id");

                

                this.Push(refId, qrCodeRefId, name, address, tel, fax);

            }

Like 0

Like

2 comments

Hi Toan Mai,

Try to name your Id column:

var idColumnName = esq.AddColumn("Id").Name;

then you can get in your foreach loop:

entity.GetTypedColumnValue<Guid>(idColumnName);

At least it worked for me.

Got the same thing yesterday : 

Replace :

esqDetails.AddColumn("Id");

 by 

esqDetails.PrimaryQueryColumn.IsAlwaysSelect = true;

And you can use the following to get the Id column : 

var recordId = details.PrimaryColumnValue;

 

Show all comments