I think the entity framework omits the relation table AC when generating the entites, and instead generates and populates the ICollection properties. In essence it makes the many-2-many relation invisible. To get all entities from TableA which has a relation to TableC = 5, you can directly make a LINQ query to this ICollection:
from ta in TableA
where ta.TableC.Any(tc => tc.Id == 5)
select ta;
UPDATE:
As Tough Coder mentioned - LINQPad truly is your friend when it comes to testing linq queries. Not to mention that is invaluable as a code scratchpad (just testing small samples without firing up a completely new VS project). I just made a complete sample to illustrate the entity relation and linq query you need:
void Main()
{
List<TableA> ta = new List<TableA>();
var ta1 = new TableA() { Id = 1 };
var ta2 = new TableA() { Id = 2 };
var ta3 = new TableA() { Id = 3 };
ta.Add(ta1);
ta.Add(ta2);
ta.Add(ta3);
var tc1 = new TableC() { Id = 1 };
var tc2 = new TableC() { Id = 2 };
var tc3 = new TableC() { Id = 3 };
ta1.TableCs.Add(tc1);
ta1.TableCs.Add(tc3);
ta2.TableCs.Add(tc1);
ta3.TableCs.Add(tc2);
ta3.TableCs.Add(tc3);
var res = from t in ta
where t.TableCs.Any(tc => tc.Id == 3)
select t.Id;
foreach (var t in res)
{
Console.WriteLine(t);
}
}
public class TableA
{
public int Id {get;set;}
public List<TableC> TableCs{get;set;}
public TableA()
{
TableCs = new List<TableC>();
}
}
public class TableC
{
public int Id {get;set;}
public List<TableA> TableAs{get;set;}
public TableC()
{
TableAs = new List<TableA>();
}
}