locked
Service Operation with special characters in a string query RRS feed

  • Question

  • Hi to all, I need to do this:

    Context .CreateQuery("SearchTransmission") .AddQueryOption("query", "'" + realQuery + "'") .ToList();

    where query is this:

    it.PlannedStartTime = DATETIME'2009-06-16 21:54' && it.PlannedEndTime = DATETIME'2009-06-16 21:54' && it.TransmissionContent.IdTransmissionContent = 6 && EXISTS (SELECT te FROM it.TransmissionElement AS te WHERE te.IsContribution = False && (te.Channel.Television.IdTelevision IN {5, 6}) && EXISTS (SELECT tvGroup FROM te.Channel.Television.TelevisionGroup AS tvGroup WHERE tvGroup.IdTelevisionGroup in {2, 3}) && (te.Channel.Via.IdVia IN {1, 12}) )&& EXISTS (SELECT te FROM it.TransmissionElement AS te WHERE te.IsContribution = True && (te.Channel.Television.IdTelevision IN {5, 6}) && EXISTS (SELECT tvGroup FROM te.Channel.Television.TelevisionGroup AS tvGroup WHERE tvGroup.IdTelevisionGroup in {2, 3}) && (te.Channel.Via.IdVia IN {3, 4}) ) && EXISTS (SELECT te FROM it.TransmissionElement AS te WHERE (EXISTS (SELECT bi FROM te.BillingItem AS bi WHERE bi.IdBillingItem IN {2, 3}))) && EXISTS (SELECT te FROM it.TransmissionElement AS te WHERE te.Incident.IncidentType.IdIncidentType IN {2, 4})


    I know that it has lots of special characters and I try to scape it with Uri.EscapeDataString(query) and HttpUtility.ParseQueryString(query) but nothing. Could you help me to pass it correctly to the service operator please? Thanks in advance :)


    I'm manually parsing the query replacing, for example, && for %26%26 and it works but I'd like a more straightforward solution...
    Tuesday, June 16, 2009 8:02 PM

Answers

  • The final fix:

    I use Uri.EscapeDataString(realQuery) static method, but I'm still having problems with the ' special character, then, I use the Replace() method in both service sides, client and service (in the service operation).

    Phani Raj tell me to use ExecuteBatch methos but I had the same problems.

    Thanks Phani! ;)
    Thursday, June 18, 2009 9:10 AM