Hi,
I don’t fully understand the logic of Locode/AutoQuery, so I would like to ask someone for help!
How can I solve that if there is a class:
public class TableA
{
public long Id { get; set; }
public string Name { get; set; }
public string F1 { get; set; }
public string F2 { get; set; }
public string F3 { get; set; }
}
Should only Id and Name be in the Query and should Update also work?
public class QueryCustomTableA : QueryDb<TableA, CustomTableA> { }
public class CustomTableA
{
public long Id { get; set; }
public string Name { get; set; }
}
public class UpdateTableA: IPatchDb, IReturn
{
public long Id { get; set; }
public string Name { get; set; }
public string F1 { get; set; }
public string F2 { get; set; }
public string F3 { get; set; }
}
in the case of the Update form contains all the fields of the TableA, but not all data.
F1, F2, F3 are empty.
Or am I approaching it completely wrong and this is already customization?
In this case, what is the recommended approach?
Thanks for the answer!
In the example you provided, IPatchDb doesn’t have a table to work on, you need to specify or in your case IPatchDb<TableA>.
With your QueryCustomTableA, are you trying to make a join to another table?
Its not clear what you are trying to achieve from your post. If you could outline clearly what you are trying to achieve, the behaviour you expect, etc, I can better guide you to how to use AutoQuery for your use case. Thanks.
Ok, sorry, I tried to simplify, but here the full code:
[Description("TableA")]
[Notes("Register of TableA")]
public class TableA
{
[AutoIncrement]
[PrimaryKey]
public long Id { get; set; }
[Required]
[Unique]
[Index(Unique = true)]
public string Name { get; set; }
[Required]
public string F1 { get; set; }
[Required]
public string F2 { get; set; }
[Required]
public string F3 { get; set; }
}
[Route("/tablea")]
public class QueryTableA : QueryDb<TableA, CustomTableA> { }
public class CustomTableA
{
public long Id { get; set; }
public string Name { get; set; }
}
public class CreateTableA : ICreateDb<TableA>, IReturn<IdResponse>
{
[Required]
public string Name { get; set; }
[Required]
public string F1 { get; set; }
[Required]
public string F2 { get; set; }
[Required]
public string F3 { get; set; }
}
public class UpdateTableA: IPatchDb<TableA>, IReturn<IdResponse>
{
public long Id { get; set; }
[Required]
public string Name { get; set; }
[Required]
public string F1 { get; set; }
[Required]
public string F2 { get; set; }
[Required]
public string F3 { get; set; }
}
Right, Update is getting existing values by performing a Query which is returning your CustomTableA DTO which only has Id and Name, so those are the only ones pre-populated. The Locode UI can only use data it can access via your AutoQuery APIs. The Create you populated yourself, the Query is listing what is being returned, and the Update is populating from the Query.