none
QueryExpression lässt sich nicht ausführen RRS feed

  • Frage

  • Hallo,

    ich habe mir mit Stunnware eine Abfrage erstellt. Hier funktioniert diese auch.... Wenn ich dann die Abfrage in meinen Quellcode übernehme geht die Abfrage leider nicht mehr. Leider sehe ich nicht was falsch läuft...

                Log(logLevel.VERBOSE, "...getting person");
                Owner result = new Owner();
                result.type = EntityName.systemuser.ToString();
                result.Value = defaultPerson.Value;
    
    
                ConditionExpression conditionCountry = new ConditionExpression();
                conditionCountry.AttributeName = "rz_countryid";
                conditionCountry.Operator = ConditionOperator.Equal;
                conditionCountry.Values = new Object[] { country.Value };
    
                Log(logLevel.VERBOSE, "query countryid: " + country.Value.ToString());
    
                ConditionExpression conditionPersonType = new ConditionExpression();
                conditionPersonType.AttributeName = "rz_responsibilityid";
                conditionPersonType.Operator = ConditionOperator.Equal;
                conditionPersonType.Values = new Object[] { personTypeGuid };
    
                Log(logLevel.VERBOSE, "query rz_responsibilityid: " + personTypeGuid.ToString());
    
                ConditionExpression conditionZip = new ConditionExpression();
                conditionPersonType.AttributeName = "rz_zippostalcode";
                conditionPersonType.Operator = ConditionOperator.Equal;
                conditionPersonType.Values = new Object[] { zip };
    
                Log(logLevel.VERBOSE, "query zip: " + zip);
    
                QueryExpression queryPerson = new QueryExpression("rz_responsibilityassignment");
                queryPerson.ColumnSet = new AllColumns();
                queryPerson.Criteria = new FilterExpression();
                queryPerson.Criteria.FilterOperator = LogicalOperator.And;
                queryPerson.Criteria.Conditions.AddRange(new ConditionExpression[] { conditionCountry, conditionPersonType, conditionZip });
    
                RetrieveMultipleRequest retrievePerson = new RetrieveMultipleRequest();
    
                retrievePerson.Query = queryPerson;
                retrievePerson.ReturnDynamicEntities = true;
    
                RetrieveMultipleResponse retrievedPersons = null;
                try
                {
                    object testa = crmService.Execute(retrievePerson);
                    Log(logLevel.VERBOSE, "objectname: " + testa.ToString());
    
                    retrievedPersons = (RetrieveMultipleResponse)testa;
    
                    foreach (Property p in ((DynamicEntity)retrievedPersons.BusinessEntityCollection.BusinessEntities[0]).Properties)
                    {
                        Log(logLevel.VERBOSE, String.Format("name: {0}, value: {1}", p.Name, ((DynamicEntity)retrievedPersons.BusinessEntityCollection.BusinessEntities[0]).Properties[p.Name]));
                    }
                }
                catch (Exception ex)
                {
                    Log(logLevel.ERROR, "get rz_responsibilityassignment: " + ex.Message);
                }
    
    

     

    Dienstag, 17. Januar 2012 14:11

Antworten

  • Upps, der Wald und die vielen Bäume!
    
                ConditionExpression conditionPersonType = new ConditionExpression();
                conditionPersonType.AttributeName = "rz_responsibilityid";
                conditionPersonType.Operator = ConditionOperator.Equal;
                conditionPersonType.Values = new Object[] { personTypeGuid };
    
                Log(logLevel.VERBOSE, "query rz_responsibilityid: " + personTypeGuid.ToString());
    
                ConditionExpression <strong>conditionZip</strong> = new ConditionExpression();
                <strong>conditionPersonType</strong>.AttributeName = "rz_zippostalcode";
                <strong>conditionPersonType</strong>.Operator = ConditionOperator.Equal;
                <strong>conditionPersonType</strong>.Values = new Object[] { zip };
    
    
    
    Wer eine conditionZip anlegt sollte auch hier die Attribute setzen. SORRY!
    • Als Antwort markiert KriegerK Dienstag, 17. Januar 2012 14:45
    Dienstag, 17. Januar 2012 14:45
  • Hallo KriegerK,

    dein Code wird deutlich einfacher, wenn du die Helperfunktionen verwendest:

    query.Criteria.AddCondition("rz_responsibilityid", ConditionOperator.Equal, personTypeGuid);
    query.Criteria.AddCondition("rz_zippostalcode", ConditionOperator.Equal, zip);
    
    Viele Grüße,

    Jürgen


    Jürgen Beck

    Dipl. Kfm./Wirtschaftsinformatik
    MVP, MCSD.NET, MCITP DBA, MCDBA, MCSE
    Microsoft Certified Business Management Solutions Professional
    Microsoft Certified CRM Developer
    Microsoft Certified Trainer

    ComBeck IT Services & Business Solutions
    Microsoft Gold Certified Partner
    Microsoft Small Business Specialist

    Developing & Supporting Business Applications from small business to big enterprises covering scores of sectors

    http://www.combeck.de

    Samstag, 18. Februar 2012 10:11
    Moderator

Alle Antworten

  • Upps, der Wald und die vielen Bäume!
    
                ConditionExpression conditionPersonType = new ConditionExpression();
                conditionPersonType.AttributeName = "rz_responsibilityid";
                conditionPersonType.Operator = ConditionOperator.Equal;
                conditionPersonType.Values = new Object[] { personTypeGuid };
    
                Log(logLevel.VERBOSE, "query rz_responsibilityid: " + personTypeGuid.ToString());
    
                ConditionExpression <strong>conditionZip</strong> = new ConditionExpression();
                <strong>conditionPersonType</strong>.AttributeName = "rz_zippostalcode";
                <strong>conditionPersonType</strong>.Operator = ConditionOperator.Equal;
                <strong>conditionPersonType</strong>.Values = new Object[] { zip };
    
    
    
    Wer eine conditionZip anlegt sollte auch hier die Attribute setzen. SORRY!
    • Als Antwort markiert KriegerK Dienstag, 17. Januar 2012 14:45
    Dienstag, 17. Januar 2012 14:45
  • Hallo KriegerK,

    dein Code wird deutlich einfacher, wenn du die Helperfunktionen verwendest:

    query.Criteria.AddCondition("rz_responsibilityid", ConditionOperator.Equal, personTypeGuid);
    query.Criteria.AddCondition("rz_zippostalcode", ConditionOperator.Equal, zip);
    
    Viele Grüße,

    Jürgen


    Jürgen Beck

    Dipl. Kfm./Wirtschaftsinformatik
    MVP, MCSD.NET, MCITP DBA, MCDBA, MCSE
    Microsoft Certified Business Management Solutions Professional
    Microsoft Certified CRM Developer
    Microsoft Certified Trainer

    ComBeck IT Services & Business Solutions
    Microsoft Gold Certified Partner
    Microsoft Small Business Specialist

    Developing & Supporting Business Applications from small business to big enterprises covering scores of sectors

    http://www.combeck.de

    Samstag, 18. Februar 2012 10:11
    Moderator