Using Adapter pattern, compiling for .NET 3.5, version 2.6.09.0116
I'm having difficulty in using Expressions correctly. I'm trying to represent a SQL query that looks like this:
UPDATE Quote
set HasPriceUpdateDocs =
(CASE WHEN EXISTS(SELECT qdcpo.QuoteId FROM QuoteDocumentCorePriceOffset qdcpo WHERE qdcpo.QuoteId = @quoteId) THEN 1 ELSE 0 END)
WHERE
Quote.Id = @quoteId
Essentially I want to set HasPriceUpdateDocs to true if there's any rows in the QuoteDocumentCorePriceOffset table with a quote id equal to my parameter, setting it to false otherwise. This is easy enough to do with a GetScalar fetch then an update, but I'd prefer to do it in one go.
What I've got so far is:
var quoteUpdate = new QuoteEntity();
quoteUpdate.Fields[(int) QuoteFieldIndex.HasPriceUpdateDocs].ExpressionToApply = new ScalarQueryExpression(????);
var adapter = new DataAccessAdapter();
adapter.UpdateEntitiesDirectly(quoteUpdate, new RelationPredicateBucket(QuoteFields.Id == quoteId));
but I've no idea what should go in ScalarQueryExpression, especially since there's no Exists aggregation, only Count.
Thanks, Stephen