Useful for building up conditional queries.
In most cases, before loading an entity or collection,
you should instantiate a new one. This method was added
to handle specialized circumstances, and should not be
used as a substitute for that.
| C# | Visual Basic |
public void QueryReset()
Public Sub QueryReset
This just sets obj.Query to null/Nothing.
In most cases, you will 'new' your object before
loading it, rather than calling this method.
It only affects obj.Query.Load(), so is not useful
when Joins are involved, or for many other situations.
Because it clears out any obj.Query.Where clauses,
it can be useful for building conditional queries on the fly.
CopyC#
CopyVB.NET
public bool ReQuery(string lastName, string firstName) { this.QueryReset(); if(!String.IsNullOrEmpty(lastName)) { this.Query.Where( this.Query.LastName == lastName); } if(!String.IsNullOrEmpty(firstName)) { this.Query.Where( this.Query.FirstName == firstName); } return this.Query.Load(); }
Public Function ReQuery(ByVal lastName As String, _ ByVal firstName As String) As Boolean Me.QueryReset() If Not [String].IsNullOrEmpty(lastName) Then Me.Query.Where(Me.Query.LastName = lastName) End If If Not [String].IsNullOrEmpty(firstName) Then Me.Query.Where(Me.Query.FirstName = firstName) End If Return Me.Query.Load() End Function
