Click or drag to resize
XWhereAndIsNotNull Method (String, BsonValue)
Created new XWhere to check if field and value is not null using AndIsNotNull operation .

Namespace:  Biolomics.SharedClasses
Assembly:  Biolomics.SharedClasses (in Biolomics.SharedClasses.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
public static XWhere AndIsNotNull(
	string p_FieldName,
	BsonValue p_Value
)

Parameters

p_FieldName
Type: SystemString
Name of the field.
p_Value
Type: BsonValue
The value.

Return Value

Type: XWhere
XWhere.
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