Click here to Skip to main content
16,004,806 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
SQL
dl1.DataSource = from st in obj.Wishlist_tables
                 join X in obj.movie_details on st.movie_id equals X.Id
                 where st.username == Session["user"].ToString()
                 select new {st, X };
dl1.DataBind();

This query is not taking result from both tables. Anyone who can do this correctly?
Posted
v2
Comments
Jameel VM 13-Sep-13 7:25am    
what is the pblm?
Pleas elaborate the scenario and issue.
Tejas Vaishnav 13-Sep-13 8:14am    
and the problem is...?

SQL
from st in obj.Wishlist_tables
                             join X in obj.movie_details on st.movie_id equals X.Id
                             where st.username == Session["user"].ToString()
                             select new { X.Image_path, X.label, X.Movie_Name, X.price, st.movie_id, st.movie_name, st.username };
 
Share this answer
 
First try the same query in native SQL and see if it returns any result. It can be that there are no matching records in Db or the user is not matching. Make sure you use equi-join in sql.
If there are specific errors then post details of the same, showing a snippet of table's structure with data.

Apart, there is nothing wrong in pure syntax terms with your query
 
Share this answer
 
SQL
from st in obj.Wishlist_tables
                             join X in obj.movie_details on st.movie_id equals X.Id
                             where st.username==Session["user"].ToString()
                             select new { X.Image_path,X.label,X.Movie_Name,X.price,st.movie_id,st.movie_name,st.username};
 
Share this answer
 
SQL
from st in obj.Wishlist_tables
                join X in obj.movie_details on st.movie_id equals X.Id
                where st.username == Session["user"].ToString()
                select new { st, X };


var data = from l in linq.tbl_countries 
           join m in linq.tbl_states on l.country_id equals m.country_id
           where l.country_name == "India" 
           select new { l.country_name, m.state_name };

In above example, your query is correct same as i written my own joining query but when you working with joining in any where it's happen when both table related to each other with same id as call parent or child so that time you should to mansion the field name also as using alias like "st.fieldname,X.fieldname". 

I hope it's working for you thanx......:) 
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900