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.
Thanks, I guessed right away, but I’d really appreciate a suggestion, even how others users solve it, because I don’t think it’s a unique requirement.This is the Query->Get Single Data with ID->Update logic.
In this solution, on the other hand, whoever has the Update right on the record can only work on Queries that contain all the data for the Update.
This seems quite a waste of resources, and it is difficult to manage that we use the same Query several times or that we have to multiply Queries just so that people with different authorizations have the necessary data.
If I have three types of users with different rights who have access to three different subsets of a given record, do I have to produce an additional Query containing 3 different data just for this reason, so that there is data for the Update, but not access to the others?
So I would appreciate any suggestions, because at the moment I see that almost every form has to be customized?
But maybe I completely misunderstood the whole logic, and what I described can be easily solved in another way.
Very Thanks!
If the query requires different authorization requirements and returns a different structure then they should be different APIs.
There’s no magic solution, Locode and all Blazor/Vue auto form components doesn’t use any backdoors, i.e. they all call your public APIs to fetch its data and update the data model and to display its AutoForm UIs. If you want to only maintain one API then you would need to build your own Custom UI that supports your custom requirements.
The examples only include modifications to the specific Query and Update APIs.The Query must still contain all data for the Update to work.If I could modify, where the CustomTableA data is passed by the Query to the Update, then I could expand the data passed to the Update, and the entire table would not have to be queried in every Query, just so that it would be passed to the Update.
Still unclear what is being asked, but the data to update a data model comes from the form which is generated from the typed structure of the Update DTO.