Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
fetch cats and products
var cat = RebaContext.CategoryLanguages
.SingleOrDefault(cl => cl.Slug == categoryName && cl.Language.Iso == culture);
var categoryAndProducts = new ShowProductsModel
{
Category = cat.Title,
Products = cat.Category.Products
.Select(p => new ShowProductsProductModel
{
Id = p.Id,
ShortDescription = p.Languages.FirstOrDefault(l => l.Language.Iso == culture).ShortDescription,
Title = p.Languages.FirstOrDefault(l => l.Language.Iso == culture).Title
})
};
@Vannevelj

This comment has been minimized.

Copy link

Vannevelj commented Jan 17, 2015

var cat = RebaContext.CategoryLanguages
.SingleOrDefault(cl => cl => cl.Slug == categoryName && cl.Language.Iso == culture)
.Select(new ShowProductsModel
{
Category = cat.Title,
Products = cat.Category.Products
.Select(p => new ShowProductsProductModel
{
Id = p.Id,
ShortDescription = p.Languages.FirstOrDefault(l => l.Language.Iso == culture).ShortDescription,
Title = p.Languages.FirstOrDefault(l => l.Language.Iso == culture).Title
})
};

@annemartijn0

This comment has been minimized.

Copy link
Owner Author

annemartijn0 commented Jan 17, 2015

You cannot Select() on a SingleOrDefault() Result.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.