I am assuming you have already a dataContext which contains 2 DbSet of each classes. Regarding that you can use: Regarding the result you expect, you can create a new class which matches with the result:
public class DistrictWithState
{
public string cDistrictName {get;set;}
public string cStateName {get; set;}
public int nStateId {get;set;}
}
Then in your Action:
var dataContext = new PetaPoco.Database("mysql");
var sql="select d.cDistrictName,s.cStateName, d.nStateID from District
d inner join States s on d.nStateID=s.nStateID";
var districts = db.Fetch<DistrictWithState>(sql);
return view(districts);
There is another solution using the dynamic
keyword. But just start with that solution above. It should work. I hope it will help