henkmollema/Dommel

Regarding joins and relation

guicamarotto opened this issue · 1 comments

Hi all, I was trying to do something and wondering if it is possible without using hardcoded querys.

I have 3 tables and entities, they are Queue, Status and Order.

on the Queue I have a mapped property StatusId, a Ignored nested object Status, a Ignored property OrderNumber, and a mapped property ServiceId
on the Order I have the mapped property ServiceId and the mapped property OrderNumber

what I want is get the Status object together with Queue, and fill the OrderNumber doing a join with Order by the ServiceId, but I need to get all of it in a List filtering by ID

For example, I am doing this right now:

var list = connect.Connection.Select<Queue>(x => x.Id== fileId).ToList();

foreach (var item in list)
            {
                item.Status = _statusRepository.GetStatusById(item.StatusId);
                item.OrderNumber = GetOrderByService(item.ServiceId).OrderNumber;
            }

there is some way to do something like this below, but returning a list and filtering by queue id?

var queueList = connect.Connection.Get<SOQueue, Status, SOQueue>(x => x.id == fileId, (queue, status) =>
                {
                    queue.Status = status;
                    OrderNumber = GetOrderByService(item.ServiceId).OrderNumber;
                    return queue;
                }).ToList(); //<-- to list not working in this scenario

No sorry, Select does not allow joining other tables as well.