I have a code flow like this:


I have first the GetRooms aggregate then I have a foreach GetRooms.List to save the each RoomId in a local variable RoomIds. After the foreach there is a SQL query "GetRoomInfo" that gets info from an external database about a specific RoomId, so in the query is used the in operator, where the "RoomID" is in the parameter @RoomIds (RoomIds local variable).


Then I have a foreach to fetch the "GetRooms.List" and a ListFilter to fetch the "GetRoomInfo" with a condition, if the current RoomId of the "GetRoomInfo" is equal to the current RoomId of the "GetRoomInfo". When this is true I have an assign that stores some info that is returned by the "GetRommInfo" for a specific RoomId by an external database. And then there is an "SQL1" that is an insert that has as parameters info returned by the "GetRoomInfo" query (like RoomNumber and other columns values).


Doubt:

The issue is that I have a foreach inside a foreach, if there are a lot of results its not very performant. So I was trying to adapt this example using hashtables but I'm understanding how to properly adapt this example to hashtables. I  maintained the aggregate GetRooms, the RoomIds local variable and then the SQL query "GetRoomInfo". After this, I added the CreateHashTable server action, but now Im not understanding properly how to adapt the example above to hashtable. Do you know how that can be done?



I don't see a foreach inside another. What I see is two foreachs (and over the same list? fix that second name).

Regarding your question, there are several hashtable components in the forge that you can try, but I don't think you need that. Your problem is that you are fetching external data. That is a probable performance issue. Assuming a hotel can have hundreds of rooms, you should probably do that on a timer, in small batches.

Thanks, but I'm just doing this test for learning purposes and Im trying to understand how to use the hashtable in this example. I already have the components (createHashTable, add, get, containsKey) but Im not understanding how to adapt this flow with a for each and ListFilter to use the hashtable instead, so that I use the get server action to access directly the necessary info for a specific RoomId to use in the assign and insert. For example, in this context, I'm not understanding where to use the add server action and the get server action.