How to get specified Entity from TMappedCollection

Discussion of open issues, suggestions and bugs regarding EntityDAC
Post Reply
ajablono
Posts: 1
Joined: Tue 26 Oct 2021 06:52

How to get specified Entity from TMappedCollection

Post by ajablono » Thu 06 Jan 2022 18:59

Hi,
i'm newbe in the Entity-World ;-)
how i can get a entity from a collection according to spectial atributes and values ( like TDataSet.Locate () ).
Currently i'm do ot with an loop:
for ASetting in ASettings do
begin
if ASetting.ArticleNumber =5 then
begin
// i found the entity in the collection
Break;
end;

end;

But this is very primitive solution.
Can somebody help me with better solution?
Greetings Andy

MaximG
Devart Team
Posts: 1776
Joined: Mon 06 Jul 2015 11:34

Re: How to get specified Entity from TMappedCollection

Post by MaximG » Thu 13 Jan 2022 22:47

EntityDAC doesn't have a method similar to TDataSet.Locate. You can implement a similar behavior by retrieving every item from a collection, as shown in the EntityDAC demo ("Get Entities by Collections"). Another way is to find the needed element using a LINQ expression.

Post Reply