locked
How to query on attribute value "not null" with querybyattribute ? RRS feed

  • Question

  • Hi,
    I'm using QueryByAttribute and I need to check that the attribute "id" is not null.
    allcontacts.Attributes = new string[] { "id" };
    allcontacts.Values = new object[] { XXXX };
    I need to replace XXXX with an expression to indicate Not Null value.

    Can you please help me with that ?

    Thanks

    M

    EDIT:
    I'm doing this because i need to retrieve all the contacts i have in my crm using QueryByAttribute, without adding an attribute, I'm receiving an error that the query attribute array cannot be empty. So I'm adding a dummy attribute just to have an attribute check.

    • Edited by SB User Wednesday, January 15, 2014 1:34 PM Clarification
    Wednesday, January 15, 2014 1:31 PM

Answers

  • Hi,

    I think this is not possible using QueryByAttribute. Use QueryExpression like as below :

    QueryExpression _Query = new QueryExpression
                    {
                        EntityName = "contact",
                        ColumnSet = new ColumnSet(true),
                    };

    If contacts records are more than 5000 then implement paging cookie  feature.

    http://msdn.microsoft.com/en-us/library/gg327917.aspx


    Hope this helps. If you get answer of your question, please mark the response as an answer and vote as helpful !!!
    Vikram Singh. !!!  My Blog

    • Marked as answer by SB User Wednesday, January 22, 2014 8:49 AM
    Wednesday, January 15, 2014 1:57 PM