WCF linq to query from multiple table RRS feed

  • Question

  • i have two tables Employee and Permenent table. permenet table is a ISA table of Employee here is the schema of two tables

    create table employees(
    employee_no varchar(5),
    name varchar(50),
    nic varchar(10),
    address varchar(100),
    designation varchar(20),
    Land varchar(10),
    Mobile varchar(10),  
    constraint pkemployees primary key(employee_no),
    constraint fkemployees foreign key(land,mobile) references telephone)
    create table permenenet(
    username varchar(20),
    password varchar(10),
    password_hint varchar(50),
    employee_no varchar(5),
    constraint fkpermenet foreign key(employee_no) references employees,
    constraint pkpermenet primary key(employee_no).

    i have created WCF service to get the name and designation

        public List<employee>get_name(string uname){
                     var resl = (from per in dc.permenenets
                     join emp in dc.employees on per.employee_no equals emp.employee_no
                     where  per.username == uname && per.employee_no == emp.employee_no 
                     select emp);
         return resl.ToList();

    but when i am testing with WCF client or getting data from WPF application i am getting empty answers.Help is appreciated

    Saturday, September 13, 2014 4:51 AM


  • What are you using Entity Framework or what?

    If the code above is in a WCF service method, than that's a no no.

    The WCF service should have reference to a classlib project called a DAL (Data Access Layer) where all database activity occurs. The WCF service method calls the DAL method for any database processing.

    The WCF service is only the conduit ( or a pass through) between the client and the DAL when the client wants database access.

    You can test the DAL method individually to know that it works without involving WCF period. So, when you hook the WCF and DAL together, you have good take that things should work. 

    Sunday, September 14, 2014 10:14 PM