Click or drag to resize
XWhere Class
This class contains a "WHERE" like query: Name LIKE 'Van%" Query1 OR Query2 Query1 AND Id >= 0
Inheritance Hierarchy

Namespace:  Biolomics.SharedClasses
Assembly:  Biolomics.SharedClasses (in Biolomics.SharedClasses.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
public class XWhere : IXmlSerializable

The XWhere type exposes the following members.

Properties
  NameDescription
Public propertyFieldName
Gets the name of the field.
Public propertyOperation
Gets the operation.
Public propertyPreOperation
Gets the pre operation.
Public propertyPreValue
Gets the pre value.
Public propertyValue
Gets the value.
Public propertyWhereX
Gets the X xwhere.
Public propertyWhereY
Gets the Y xwhere.
Top
Methods
  NameDescription
Public methodStatic memberCode exampleAll
return a where clause doing nothing: Operation = none to return all records
Public methodCode exampleAnd_(XWhere)
Concats given XWhere statement with current XWhere using AND operator.
Public methodStatic memberCode exampleAnd_(XWhere, XWhere)
Created new XWhere using AND operator between given XWhere statements.
Public methodCode exampleAnd_(String, XWhereOperationEnum, BsonValue)
Created new XWhere with And operator to add new xwhere statement based on field name and operation and value to current xwhere statement.
Public methodCode exampleAnd_(XWherePreOperationEnum, String, XWhereOperationEnum, BsonValue)
Created new XWhere with And operator to add new xwhere statement based on field name ,preoperation, operation and value to current xwhere statement.
Public methodCode exampleAnd_(XWherePreOperationEnum, BsonValue, String, XWhereOperationEnum, BsonValue)
Created new XWhere with And operator to add new xwhere statement based on field name ,preoperation,prevalue, operation and value to current xwhere statement.
Public methodStatic memberCode exampleAndIsNotNull(String, BsonValue)
Created new XWhere to check if field and value is not null using AndIsNotNull operation .
Public methodStatic memberAndIsNotNull(String, String, BsonValue)
Public methodStatic memberCode exampleAndIsNull(String, BsonValue)
Created new XWhere to check if field and value is null using AndIsNull operation .
Public methodStatic memberAndIsNull(String, String, BsonValue)
Public methodClear
Resets the xwhere. See the default constructor
Public methodStatic memberCode exampleContains(String, BsonArray)
Created new XWhere with Contains operation to check if field name contains any value from the bson array.
Public methodStatic memberCode exampleContains(String, BsonValue)
Created new XWhere with Contains operation to check if field contains the value.
Public methodStatic memberCode exampleContains(XWherePreOperationEnum, String, BsonValue)
Created new XWhere with Contains operation to check if field contains the value with preoperation.
Public methodStatic memberEmpty
Returns an Empty dataset.
Public methodStatic memberCode exampleEndWith
Created new XWhere with EndsWith operation to check if field ends with the value.
Public methodStatic memberCode exampleEq(String, BsonValue)
Created new XWhere with Equal operation .
Public methodStatic memberCode exampleEq(XWherePreOperationEnum, String, BsonValue)
Created new XWhere with Equal operation using preoperation.
Public methodStatic memberCode exampleEq(XWherePreOperationEnum, BsonValue, String, BsonValue)
Created new XWhere with Equal operation using preoperation and prevalue.
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodStatic memberCode exampleGt(String, BsonValue)
Created new XWhere with Greater operation .
Public methodStatic memberCode exampleGt(XWherePreOperationEnum, String, BsonValue)
Created new XWhere with Greater operation using preoperation .
Public methodStatic memberCode exampleGte(String, BsonValue)
Created new XWhere with Greater or Equal operation .
Public methodStatic memberCode exampleGte(XWherePreOperationEnum, String, BsonValue)
Created new XWhere with Greater or Equal operation using preoperation.
Public methodStatic memberCode exampleIn_(String, BsonArray)
Created new XWhere with In operation to check if the field value is in an array.
Public methodStatic memberCode exampleIn_(XWherePreOperationEnum, String, BsonArray)
Created new XWhere with In operation to check if the field value is in an array using preoperation.
Public methodStatic memberCode exampleInRange
Created new XWhere with InRange operation to check if the field value is in an array .
Public methodCode exampleIsAll
Determines whether this instance contains xwhere.All.
Public methodCode exampleIsEmpty
Determines whether this xwhere contains an Empty xwher.
Public methodStatic memberCode exampleIsEmptyLink
Created new XWhere to check if the link is Empty.
Public methodStatic memberCode exampleIsNotEmptyLink
Created new XWhere to check if the link is not Empty.
Public methodStatic memberCode exampleIsNotNull
Created new XWhere with INotsNull operation to check if field is not null.
Public methodStatic memberCode exampleIsNotNullArray
Created new XWhere with IsNotNullArray operation to check if field is not a null array.
Public methodStatic memberCode exampleIsNull
Created new XWhere with IsNull operation to check if field is null.
Public methodStatic memberCode exampleIsNullArray
Created new XWhere with IsNullArray operation to check if field is a null array.
Public methodStatic memberCode exampleLt(String, BsonValue)
Created new XWhere with Less than operation .
Public methodStatic memberCode exampleLt(XWherePreOperationEnum, String, BsonValue)
Created new XWhere with Less than operation using preoperation .
Public methodStatic memberCode exampleLte(String, BsonValue)
Created new XWhere with Less than or Equal operation .
Public methodStatic memberCode exampleLte(XWherePreOperationEnum, String, BsonValue)
Created new XWhere with Less than or Equal operation using preoperation.
Public methodMaxId
Get the maximum id.
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodMinId
Get the minimum id.
Public methodStatic memberCode exampleModulo
Created new XWhere with Modulo operation .
Public methodStatic memberCode exampleNE(String, BsonValue)
Created new XWhere with Not Equal operation .
Public methodStatic memberCode exampleNE(XWherePreOperationEnum, String, BsonValue)
Created new XWhere with Not Equal operation using preoperation .
Public methodStatic memberCode exampleNE(XWherePreOperationEnum, BsonValue, String, BsonValue)
Created new XWhere with Not Equal operation using preoperation and prevalue .
Public methodStatic memberCode exampleNot_
Create new Xwhere statement with Not opration from given xwhere statement.
Public methodStatic memberOperationFromString
Return OperationEnum from Operation name.
Public methodCode exampleOr_(XWhere)
Join xwhere statement with current xwhere statement with OR operator
Public methodCode exampleOr_(String, XWhereOperationEnum)
Create a new xwhere statement from fieldname and operation and join it with current xwhere statement using OR operator.
Public methodStatic memberCode exampleOr_(XWhere, XWhere)
Joins two xwhere statements with OR operator
Public methodCode exampleOr_(String, XWhereOperationEnum, BsonValue)
Create a new xwhere statement from fieldname and operation and value and join it with current xwhere statement using OR operator.
Public methodCode exampleOr_(XWherePreOperationEnum, String, XWhereOperationEnum, BsonValue)
Create a new xwhere statement from fieldname and preoperation and operation and value and join it with current xwhere statement using OR operator.
Public methodCode exampleOr_(XWherePreOperationEnum, BsonValue, String, XWhereOperationEnum, BsonValue)
Create a new xwhere statement from fieldname ,preoperation,prevalue, operation and value and join it with current xwhere statement

using OR operator.

Public methodStatic memberCode exampleRegExp(String, String)
Created new XWhere with RegExp operation .
Public methodStatic memberCode exampleRegExp(XWherePreOperationEnum, String, String)
Created new XWhere with RegExp operation using preoperation.
Public methodStatic memberSimplify
used to simplify the OR queries and avoid 500 imbricated XWhere instances
Public methodStatic memberSql
Returns an xwhere with sql query.
Public methodStatic memberCode exampleStartWith
Created new XWhere with StartsWith operation.
Public methodTitle
build a title for the given Where clause, something that is understandable by most users
Public methodToString
Returns a String that represents this xwhere.
(Overrides ObjectToString.)
Top
Operators
  NameDescription
Public operatorStatic memberEquality
Check if X xwhere is equal to Y xwhere.
Public operatorStatic memberInequality
Check if X xwhere is not equal to Y xwhere.
Top
Examples
This is an example of use of XWhere class to do some queries.
Example VB.Net
Imports System
Imports System.Collections

Imports Biolomics.BioCallback
Imports Biolomics.SharedClasses
Imports Biolomics.Utility.Constants

Public Class MyNewClass

    ' This function is called when running this script
    Shared Sub Main()

        '    Create an instance of class MyNewClass and call its functions
        Dim c As New MyNewClass
        c.RunQuery()
    End Sub

    Public Sub RunQuery()

        '    *****    Run a query    in the current SearchPage    *****
        Dim Where As XWhere = XWhere.GT(StaticFields.id, 2).And_(StaticFields.id, XWhere.OperationEnum.LT, 8).Or_(StaticFields.name, XWhere.OperationEnum.EndWith, "877")

        '    *****    Numerical queries    *****
        Where = XWhere.Eq(StaticFields.id, 5)                    '    WHERE Id = 5
        Where = XWhere.NE(StaticFields.id, 5)                    '    WHERE Id != 5
        Where = XWhere.GT(StaticFields.id, 5)                    '    WHERE Id > 5
        Where = XWhere.GTE(StaticFields.id, 5)                '    WHERE Id >= 5
        Where = XWhere.LT(StaticFields.id, 5)                    '    WHERE Id < 5
        Where = XWhere.LTE(StaticFields.id, 5)                '    WHERE Id <= 5

        '    *****    String queries    *****
        Where = XWhere.Eq(StaticFields.name, "CBS 14")           '    WHERE Name = 'CBS 14'
        Where = XWhere.NE("name", "CBS 14")          '    WHERE Name != 'CBS 14'
        Where = XWhere.StartWith("name", "Apis")     '    WHERE Name LIKE 'Apis%'
        Where = XWhere.Contains("name", "mell")      '    WHERE Name LIKE '%mell%'
        Where = XWhere.EndWith("name", "mellifera")  '    WHERE Name LIKE '%mellifera'

        '    *****    Numerical list queries    *****
        Dim NumArray As Integer() = {1, 3, 5, 7, 9}
        Dim NumList As New BsonArray(NumArray)       '    from an array of values
        NumList.Add(11)   '    add a value
        Where = XWhere.In_(StaticFields.id, NumList)          '    WHERE Id IN(1, 3, 5, 7, 9, 11)

        '    *****    String list queries    *****
        Dim StrArray As String() = {"John", "Bryan", "Bob"}
        Dim StrList As New BsonArray(StrArray)       '    from an array of values
        Where = XWhere.In_(StaticFields.name, StrList)           '    WHERE Name IN("John", "Bryan", "Bob")

        '    *****    Combining queries    *****
        Where = XWhere.GTE(StaticFields.id, 5).And_(StaticFields.id, XWhere.OperationEnum.LT, 20) ' WHERE Id >= 5 AND Id < 20
        '    the operation given as the second parameter has the same name as 
        '    the static functions above: Ep, LT, LTE, GT, etc.
        '    There is no limit in the combinations, executed from left to right
        Where = XWhere.GTE(StaticFields.id, 5).And_(StaticFields.name, XWhere.OperationEnum.StartWith, "Vespa").
         And_("comment", XWhere.OperationEnum.Contains, "invasive")

        '    *****    Checking for NULL    *****
        Where = XWhere.IsNull("name")             '    WHERE Name is null
        Where = XWhere.IsNotNull("name")          '    WHERE Name is not null

        '    ***** Complex queries with bitwise pre-processing
        '    checking for bit #3 (= 4) in a value
        Where = XWhere.NE(XWhere.PreOperationEnum.BitAnd, 4, "read_group", 0)   ' WHERE (ReadGroup AND 4) <> 0
        '    checking for even values: bit #0 is not set
        Where = XWhere.Eq(XWhere.PreOperationEnum.BitAnd, 1, "read_group", 0)   ' WHERE (ReadGroup AND 1) = 0

        '    *****    Regular expressions    *****
        Where = XWhere.RegExp("name", "[[:<:]]invasive[[:>:]]")  '    WHERE Name REGEXP '[[:<:]]invasive[[:>:]]'

        '    *****    Loading everything or nothing    *****
        Where = XWhere.All
        Where = XWhere.Empty

        '    *****    Check for the content of a Where Clause    *****
        If Where.IsEmpty OrElse Where.IsAll Then
            '    ...
        End If

    End Sub

End Class
See Also