I've searched StackOverflow but still cannot understand the correct syntax to use Single, First (or default) queries.
I'm willing to make a query to catch first the translation in specific language. If there is no such translation on the db, get the first one in English.
Here is what I got so far:
locale = "ja-jp";
var items = from c in db.Contents.Include("Translation")
where c.RegionalInfo.Any(x => x.RegionId == locale)
select c;
Edit Obs.: items is an IEnumerable
Try something like this.
var item = (from c in db.Contents.Include("Translation")
where c.RegionalInfo.Any(x => x.RegionId == locale)
select c).FirstOrDefault();
if (item != null)
...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With