I have an SQL table [tbl_Test]
Contains the columns [Id], [Name], [Gender], [Age]
And another Table [tbl_Test_Addresses]
Contains the columns [AutoId], [UserId], [Address]
Now I am trying to access some data joining these two tables :
[OperationContract]
public List<Person> GetCustomerOrder()
{
DataClassesDataContext db = new DataClassesDataContext();
var Test = (
from tbl_Tests1 in db.tbl_Tests
join tbl_Test_Addresses1 in db.tbl_Test_Addresses
on tbl_Tests1.Id equals tbl_Test_Addresses1.UserId
select new CustomerOrder {
Id = tbl_Tests1.Id,
Name = tbl_Tests1.Name
}
);
return (List<Person>)Test ;
}
public class Person
{
public int Id { set; get; }
public string Name { set; get; }
}
It is not working.
But I have another table [Employee]
And when I try to fetch data in the following way
public List<Employee> GetUsers(string LastName)
{
DataClassesDataContext db = new DataClassesDataContext();
var tests = from cust in db.Employees
/* where cust.LName.StartsWith(LastName)*/
select cust;
return tests.ToList();
}
It can fetch data.
So I have problem as I try to join tables.
Can you tell me what I should do?
Thanks.