Business Logic Framework - Tutorial 37:
LINQ makes it easy to specify search criteria using the where clause/keyword. Quick Objects can handle even the most complex criteria and ensure that they are properly applied in the SQL query for the target database platform. This tutorial shows how you can use the Contains method and Length property of a "string" field to specify criteria.
| using (Customers customers = new Customers()) |
| { |
| // you can use Contains, StartsWith, EndsWith methods and the Length property on String values |
| var result = from c in customers |
| where |
| c.FirstName.Value.Contains("i") |
| || |
| c.LastName.Value.Length > 2 |
| select c; |
| foreach (var v in result) |
| { |
| // We can simply use IsNull property of the field like we do it in the business object to check if the field is null or not. |
| if (!v.CustomerID.IsNull) |
| { |
| this.listBox1.Items.Add(v.FirstName.ToString()); |
| } |
| } |
| } |
| Using customers As Customers = New Customers() |
| ' You can use Contains, StartsWith, EndsWith methods and the Length property on String values |
| Dim result = From c In customers _ |
| Where c.FirstName.Value.Contains("i") _ |
| Or c.LastName.Value.Length > 2 _ |
| Select c |
| For Each v In result |
| If Not v.CustomerID.IsNull Then |
| Me.listBox1.Items.Add(v.FirstName.ToString()) |
| End If |
| Next |
| End Using |
