I have a small LINQ problem make me crazy
I am new in the field of programming "Small Programmer".
Plz I need fast ,simple answer using my Style in coding.
My problem Is
Suppose if I have the this database
City Table : City_ID As PK ,City_Name .
Department Table : City_ID As FK ,Dept_ID As PK ,Dept_Name .
Employee Table :Dept_ID FK ,Emp_ID As PK ,Emp_Name .
1- If I have City Name In string C;
I want To retreve All Assosiated Employee Names That Works In Depaartments Placed In City that have City Name That In string C ;
2- If I have Employee Name In string E;
I want To retreve City Name where That Employee Placed In ;
my Style in coding Is:
-----------------------------------------------------------------------------------
Using Datacontext Like My simple Example here to Retreve Department name that have Employee Name In string E ;
public partial class _Default : System.Web.UI.Page
{
ProDataContext M = new ProDataContext();
protected void Page_Load(object sender, EventArgs e)
{
string E;
string D = M.Departments.Where(x => x.Dep_ID == M.Employees.Where(n => n.Emp_Name == E).Single().Dep_ID).Single().Dep_Name;
}
}
------------------------------------------------------------------------------------
Thanx.....
[edit]Code blocks sorted out - OriginalGriff[/edit]