views:

29

answers:

1

I have a relatively simple use case which is failing. Consider the following code:

[OperationBehavior(TransactionScopeRequired = true)]
public IEnumerable<StatusRecord> ReadActive(int contactID, bool isActive)
{
  var result = from n in ORM.Default.Table<StatusRecord>()
                where n.lng_contact_id == contactID && n.dte_effective_end == null
                select n;

  return result;
}

This is using a custom LINQ-SQL provider of our own evil origins. Normally this type of call works great, but when using it from a DTC Transacted WCF call, it hangs. My theory is that the serialization of the result into an array somehow occurs outside the transaction scope and therefore hangs. Furthermore, my theory is supported by the fact that changing the line

return result;

to

return result.ToArray();

makes things work. Although I am pleased to have a workaround, it seems there is a better way to get this behaving. Please advise. Thank you!

A: 

Don't use deffered execution in WCF operation. You have to execute your query before you returning result - that is what you did in result.ToArray().

Ladislav Mrnka
I follow you, but without transactions deferred execution works fine. WCF auto flattens/serializes/materialises (whatever the right word is) enumerations - was hoping I could do that here also.
Malachi