tags:

views:

275

answers:

1

I've been looking all over StackOverflow and SubSonic Project and can't find how to perform one query using a SimpleRepository where I have a Product class with a Category.

Product contains a CategoryID and Category property to make up the POCO. Category class of course contains CategoryID and CategoryName for the POCO.

When I try to do the following:

var repo = new SimpleRepository("myDBConnection");
var products = repo.All<Product>();

return View(products);

In the view I have an item.Category.CategoryName and that's where I get the runtime error.

Does SubSonic 3.0.0.3 resolve this issue? Is there a workaround other than ActiveRecord and Linq Queries to create a new Anonymous Type object in the select? Did I not find the question hidden away on S/O?

I'm starting to come to the end of my research of SubSonic for the project I'm working on and I'm probably going to start recommending a different ORM/DAL framework. I've been running into a lot of problems where I really don't have enough documentation to go off of (SubSonicProject Docs or otherwise) to help me out and I'm starting to scramble for a new SOLID solution that will speed up my coding time to play catch up.

A: 

You may have a look at this: http://stackoverflow.com/questions/1176594/subsonic-3-simplerepository

Nick Yao
Yeah I looked at that post and hoped that there would have been something new in last few days to provide a solution for SimpleRepository as the answer for the post you mention relates to ActiveRecord.I've run into some problems with ActiveRecord that have not been resolved yet. I appreciate it though.
kntcnrg
You should look at Podge's answer:var query = from product in repo.All(Product)join categoryItem in repo.All(Category)on product.CategoryId equals categoryItem.Idselect new {ID = product.ID,name = product.name,description = product.description,categoryId= product.CategoryIdcategory = categoryItem};
Nick Yao
I guess I'll create a new class that contains the fields I want in order to use the specific fields within the query. I was hoping not to do that, but that's what it's coming to. Maybe after SubSonic takes over NHibernate we'll see more features.
kntcnrg