Wiki Link: [discussion:1863]
How to filter data using EDM 

Jun 11 2009 at 11:42 AM
Edited Jun 11 2009 at 11:46 AM
I have three tables
1. Department
2. Course
3. Version

EDM result it into three entities


1. Departmnet
Properties(Id, Name)
Navigations(Courses)

2. Course
Properties(Id, Name)
Navigations(Department, Versions)

3. Version
Properties(Id, Name, Number)
Navigations(Course)





One Department may have many courses, one course may have many versions

I want to get Latest version of each course by Department ID

My code return me all version of each course by department id

private void BindGrid(GridView Grid, Guid CategoryID)
{
DataEntities data = new DataEntities();
Category cat = (from c in data.Categorys where c.ID == CategoryID select c).First();
IList<Definition> defintions = (from d in data.Definitions.Include("Versions") where d.Category.ID == cat.ID select d).ToList();
IList<DynamicForms.Data.Version> versions;
if (defintions.Count>0)
{
versions = defintions.SelectMany(d=>d.Versions).ToList();

Grid.DataSource = versions;
Grid.DataBind();
}
}

But I want to get latest version (Max Version.Number) of each course. How can i get it please.



Updating...
Page view tracker