I have a request like this:
ARequest : QueryBase<Person, Result>, IJoin<Person, OtherThing>
Person has the following field
[Ignore]
Public string Label { get { return FirstName + LastName; }
In my Result i have the following
public int Id;
public string Label
However, if i add an Ignore
attribute to a field it gets ignored. So whenever i execute everything the only thing returned is a list of id's and in the QueryResponse the Label
is always empty, if i however return a Person
instead of Result
i get a completely filled response.
So the question is, how do i make sure OrmLite does not search for label in the database, but sets the label in my custom return object.
Best How To :
After mythz explained to me the fact that if it doesn't map to your ormlite db it won't map to your resulting DTO later, i build a quick work around. Instead of returning my own response dto immediately in the following line:
ARequest : QueryBase<Person, Result>, IJoin<Person, OtherThing>
I just returned the person object:
ARequest : QueryBase<Person>, IJoin<Person, OtherThing>
Then in my service i wrote a simple mapper along the following lines:
QueryResponse<Result> response = result.ConvertTo<QueryResponse<Result>>();
response.Results = new List<Result>();
foreach (Person p in result.Results)
{
response.Results.Add(new Result{ Id = p.EmployeeId, Label = (p.FirstName + " " + p.LastName) });
}
return response
This way i made sure the label got filled with the firstname and the lastname, and yet did not have to redesign my result DTO so i could keep it very generic.