Linq where column == (null reference) not the same as column == null

Change where (s.crmc_Retail_Trade_Id == tradeId) to where (s.crmc_Retail_Trade_Id == tradeId || (tradeId == null && s.crmc_Retail_Trade_Id == null)) Edit – based on this post by Brant Lamborn, it looks like the following would do what you want: where (object.Equals(s.crmc_Retail_Trade_Id, tradeId)) The Null Semantics (LINQ to SQL) MSDN page links to some interesting info: LINQ to … Read more

Simple Examples of joining 2 and 3 table using lambda expression

Code for joining 3 tables is: var list = dc.Orders. Join(dc.Order_Details, o => o.OrderID, od => od.OrderID, (o, od) => new { OrderID = o.OrderID, OrderDate = o.OrderDate, ShipName = o.ShipName, Quantity = od.Quantity, UnitPrice = od.UnitPrice, ProductID = od.ProductID }).Join(dc.Products, a => a.ProductID, p => p.ProductID, (a, p) => new { OrderID = a.OrderID, … Read more

String.IsNullOrEmpty in LINQ To SQL query?

Curiously, per MSDN String.IsNullOrEmpty is supported (by virtue of it not being unsupported), yet I can only find complaints about it not being supported. However, if it does work you should not explicitly compare it to a boolean value, instead: var results = from result in context.Records /*XXX broke 🙁 where !String.IsNullOrEmpty(result.Info) */ where !(result.Info … Read more

C# where does the dbml file come from?

The DBML file is not related to the database server at all. It’s a completely client side thing. It’s essentially a set of information about your tables in the database and how you’re going to map them to .NET objects. Of course, you can drag a table from a database and have Visual Studio infer … Read more

LinqDataSource – Can you limit the amount of records returned?

I had this same issue. The way I got round this was to use the Selecting event on the LinqDataSource and return the result manually. e.g. protected void lnqRecentOrder_Selecting(object sender, LinqDataSourceSelectEventArgs e) { DataClassesDataContext dx = new DataClassesDataContext(); e.Result = (from o in dx.Orders where o.CustomerID == Int32.Parse(Request.QueryString[“CustomerID”]) select o).Take(5); }

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)