Administrator
VB.NET Forum Admin
- Joined
- Jun 3, 2004
- Messages
- 1,462
- Programming Experience
- 10+
I am really enjoying LINQ and how powerful it is! However, not having read any books or complete documentation on this, i.e. learning as I go, I've learned a few things that can really bite ya if you're not looking! I'm talking about LINQ with DataSets here:
1) ALWAYS ALWAYS ALWAYS put a RowState check in your WHERE clause, or if not WHERE clause, add one with a RowState check. LINQ will return rows even in RowState DELETE state which really can throw you for a loop in debugging an issue. Thankfully I use Gurock SmartInspect so the error tracing is well embedded so I get great information out of my code (and bugs). If you're not setting the WHERE clause to a specific RowState to retrieve you should probably have a WHERE item.RowState <> DataRowState.Deleted
2) The ORDER BY comes AFTER (I say again AFTER) the SELECT statement. I used the typical Dim x = From p in Data WHERE blah Order By blah SELECT p. Well, things don't quite come out like ya'd think! The fix - put ORDER BY "LASSSST!!!"
Hope this helps you out! LINQ is amazing, learn it, use it, it is THE think of VS.NET 2008 (.NET 3.5)!!!
1) ALWAYS ALWAYS ALWAYS put a RowState check in your WHERE clause, or if not WHERE clause, add one with a RowState check. LINQ will return rows even in RowState DELETE state which really can throw you for a loop in debugging an issue. Thankfully I use Gurock SmartInspect so the error tracing is well embedded so I get great information out of my code (and bugs). If you're not setting the WHERE clause to a specific RowState to retrieve you should probably have a WHERE item.RowState <> DataRowState.Deleted
2) The ORDER BY comes AFTER (I say again AFTER) the SELECT statement. I used the typical Dim x = From p in Data WHERE blah Order By blah SELECT p. Well, things don't quite come out like ya'd think! The fix - put ORDER BY "LASSSST!!!"
Hope this helps you out! LINQ is amazing, learn it, use it, it is THE think of VS.NET 2008 (.NET 3.5)!!!