1
I have a difficulty here in this lambda, I would like to know how I select the whole object without having to specify all its properties.
Like a: SELECT * FROM Somethings
Without having to specify how: SELECT ID, BLA, BLE FROM Algumacoisa
I already got a piece of how I want it:
var query = this.clientDbContext.Printers
.Where(p => p.PlaceId == placeId);
if (!getRemoved)
query = query.Where(where => where.WasRemoved == false);
if (onlyWithCounters)
query = query
.Join(this.systemDbContext.PrinterCounter, printer => printer.PrinterId, pc => pc.PrinterId, (printer, pc) => new { Printer = printer })
.Select(select => select.Printer);
I don’t know if this is the right way to do it, I would like the more experienced to help me :)
I thought that part I did:
(printer, pc) => new { Printer = printer })
That would solve
(printer, pc) => printer)
To clarify, I want to simulate this:
.Join(this.systemDbContext.PrinterCounter, printer => printer.PrinterId, pc => pc.PrinterId, (printer, pc) => new { Printer = printer })
.Select(select => select.Printer);
That:
SELECT *
FROM [*banco do cliente*].[dbo].[Printers] AS printer
JOIN [*banco principal*].[dbo].PrinterCounter AS cp ON printer.PrinterId = cp.PrinterId
Why are you using Join?
– novic
Because I want to select only Printers that have counters in Printercounter table.
– Victor Hugo Schmidt
You want to bring Printer, which has information in Printercounter? if yes post the two models and if possible the two tables!
– novic
Unfortunately I can’t show beyond that :/
– Victor Hugo Schmidt
If you can’t even put the relationship?
– novic
I need to know if it’s 1 to N? relationship you have no problem posting!
– novic
The ratio is 1 to 1.
– Victor Hugo Schmidt