Search code examples
c#jsontypescriptslickgridserenity

How can I change a column in repository.cs?


I change the day value in the list by doing some calculations. But I can't show it in the list. When I try as follows, I get the error customerId must be uniqueid. I would be happy if you help. I'm using an old version of Serenity. I'm trying to do what I show in the photo.

enter image description here

this is my repository.cs

public ListResponse List(IDbConnection connection, ListRequest request)
{
    List<dynamic> listeResmi = new List<dynamic>();
    try
    {
        connection.Open();
        listeResmi = getAllTatilListe(connection);
    }
    finally
    {
        connection.Close();
    }

    var row = new MyRow();
    var query = new SqlQuery().From(row).SelectTableFields();

    query.CountRecords = true;
    var entities = new List<MyRow>();

    ListResponse<MyRow> listReturn = new ListResponse<MyRow>();

    var totalCount = query.ForEach(connection, () =>  
    {
        var yeniGunFarki = GetDateRestriction(Convert.ToDateTime(row.VADE),listeResmi);
        row.GECIKME = Convert.ToInt32(yeniGunFarki);
        row.MUSTERIID = row.MUSTERIID;
        entities.Add(row);
    });

    listReturn.Entities =entities;
    listReturn.Skip = 0;
    listReturn.Take = 100;
    listReturn.TotalCount = totalCount;
    return listReturn;
}

It is my error json. There is MUSTERIID parameter.

Uncaught Each data element must implement a unique 'MUSTERIID' property. Object at index '0' has repeated identity value '18839376296_94d31a01-0b3b-4720-8895-13f23dc6d714': {"InsertDate":"2023-07-19T12:59:38.353","MUSTERIID":"18839376296_94d31a01-0b3b-4720-8895-13f23dc6d714"}

enter image description here


Solution

  • If MyRow is an IRow<TFields>, then your row object should have a CloneRow method:

    var totalCount = query.ForEach(connection, () =>  
    {
        var newRow = row.CloneRow() as MyRow;
    
        var yeniGunFarki = GetDateRestriction(Convert.ToDateTime(newRow.VADE),listeResmi);
        newRow.GECIKME = Convert.ToInt32(yeniGunFarki);
        newRow.MUSTERIID = row.MUSTERIID; // Not sure why this line is here. I assume you can remove it
        entities.Add(newRow);
    });
    

    Now entities will contain unique objects and if each row already has a unique MUSTERIID so should the items in entities.