You can do this using the method GroupBy:
var uniqStates = dbContext.conflocations.GroupBy(item => item.StateId).Select(g=>new {StateId=g.Key,Count=g.Count()}).ToList();
Or using the query syntax, you can also do:
var uniqStates= from conf in dbContext.conflocations
group conf by conf.StateId into g
select new {StateId=g.Key,
Count=g.Count()
};
, , State Conflocation, - :
var uniqStates= from conf in dbContext.conflocations
group conf by conf.StateId into g
select new {StateId=g.Key,
Name=g.FirstOrDefault().State.Name
Count=g.Count()
};
Update
StateWiseVenues , , :
var uniqStates= from conf in dbContext.conflocations
group conf by conf.StateId into g
select new StateWiseVenues {StateId=g.Key,
Name=g.FirstOrDefault().State.Name
Count=g.Count()
};
if(uniqStates !=null)
{
state_venues = uniqStates.ToList();
}