LINQ where clause not returning results
-
Saturday, October 06, 2012 12:24 AM
Good evening:
I have the below code:
public partial class List : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { int custId = Convert.ToInt32(Request.QueryString["c="]); TangentDataClassesDataContext db = new TangentDataClassesDataContext(); var query = from list in db.F_ShoppingLists join items in db.D_Items on list.ItemId equals items.ItemId join aisles in db.D_Aisles on items.AisleId equals aisles.AisleId where list.MemberId == custId orderby items.ItemName select new { CustomerId = list.MemberId, ItemName = items.ItemName, Price = items.Price, Quantity = list.Quantity, TotalPrice = items.Price * list.Quantity, Aisle = aisles.AisleName }; ListGrid.DataSource = query; ListGrid.DataBind(); } }
This should display the above columns in ListGrid.
My problem is that whenever I execute without that "where" clause disabled, no results are returned. If I leave the where clause disabled, I get all results.
Any ideas?
Kyle Masters
Business and Financial Intelligence Analyst - Firewind Digital Studios
Contributor - The SQL School
All Replies
-
Saturday, October 06, 2012 12:43 AM
I suspect the problem is your custId is probably not correct. THis is very likely because you should be using:
int custId = Convert.ToInt32(Request.QueryString["c"]); // Remove the =
You might want to make a more robust way to get the value, such as: http://stackoverflow.com/a/349818/65358
Reed Copsey, Jr. - http://reedcopsey.com
If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".- Marked As Answer by Kyle_Masters Saturday, October 06, 2012 1:08 AM
-
Saturday, October 06, 2012 1:08 AMThis, my friends, is what we call a *facepalm* moment. Thanks Reed.
Kyle Masters
Business and Financial Intelligence Analyst - Firewind Digital Studios
Contributor - The SQL School

