hope you can help!
I've started a project in MVC 3 and set the business domain model in another assembly, the interfaces define the contract between this assembly and all projects that will use it. I'm using Ninject to inject the dependencies into the project. I've hit a brick wall at the moment with a specific LINQ query.
public IEnumerable<ITheInterface> DoMyQuery()
{
using (ISession session = _sessionFactory.OpenSession()) {
var query = (
from c in session.Query<IMyInterface>()
where something == anotherthing
group c by new { c.TheGrouper } into grp
select new IMyInterface() {
Property = grp.Key
}
);
return query.ToList();
}
}
Now obviously I can't instantiate an interface, but this is my problem! The only way around it is to instantiate the concrete class, but that breaks my rules of being loosely coupled. Has anyone else ran into this before?
I suppose my question is, how do I use "select new Object" in a LINQ query by using the interface and NOT the concrete class?
Note: just for the record, even if I do use my concrete class to just get it to work, I get an NHibernate error of "Could not resolve property: Key of: "... but that's another issue.
Any help appreciated!!