C
C#3y ago
popcorn

Keep Model instances without RelatedModel in query

Hi, how do I keep records that do not have related model value in my query? I have a query like:
var rows = context.MyModel.
Select(x => new
{
Field1 = MyModel.Field1,
RelatedField1 = MyModel.RelatedModel.RelatedField1
})
var rows = context.MyModel.
Select(x => new
{
Field1 = MyModel.Field1,
RelatedField1 = MyModel.RelatedModel.RelatedField1
})
And all MyModel instances that do not have the RelatedModel will be excluded in that query. How can I include them and just let the value be null?
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server