I have a class where it's data comes from two difference sources - one is a database and the other is a web API.
The database source gives me most of the data, and the web API just a few properties.
I get the data from the database using Dapper, as an IEnumerable<MyClass>
(where the properties from the web API are all nulls),
and the data from the web API is an IEnumerable<WebApiClass>
.
Now I need to join these two results to a single IEnuemrable<MyClass>
- simple enough -
var query = from c in dbResults
join w in webResults on c.Id equals w.Id
select new MyClass()
{
dbProp1 = c.dbProp1, dbProp2 = c.dbProp2, ...
waProp1 = w.Prop1, waProp2 = w.Prop2, ...
}
Is there a way to do that without selecting a new MyClass()
, but simply use the already existing instances of MyClass
from dbResults
?
All the join queries I've seen use select new
- is that really the only option?