I'm kinda curious if there's a better way to accomplish what the following. Basically, I have two classes. ClassA and ClassB. ClassA has a foreign key to ClassB. I want to, from ClassB, determine all the elements from ClassA that reference ClassB. Hopefully this small example will help make more sense:
It's also worth noting I'm trying to mimic the ASP.NET MVC 4 book, in terms of "convention":
(In Entities Folder)
public class ClassA
{
[Key]
public int Id {get; set;}
public ClassB MyClassB {get;set;}
}
public class ClassB
{
[Key]
public int Id {get; set;}
public String title {get; set;}
virtual public IEnumerable<ClassA> ClassAs(IClassA a)
{ return a.ClassA.Where(....).AsEnumerable(); }
}
(In Abstract Folder)
public interface IClassA
{
IQueryable<ClassA> ClassA { get; set; }
}
public interface IClassB
{
IQueryable<ClassB> ClassB { get; set; }
}
Where I'm seeing the concern is the need to pass an instance of the object I have (In this case an instance of ClassA to the method ClassAs.
Thinking about this further, it's possible to probably also create the definition within the interface, then declare it in the concrete folder. What's the "best" way to do this? Understanding how the EF still works regarding joins is still a bit of a mystery, any interesting resources would be appreciated, too.