views:

78

answers:

0

Hi guys, i have 2 tables - products and categories. Each product belong to 1 category. When i delete category i need to delete all corresponding products, also i need to do that in transaction. So far i have this code:

    var batch = new BatchQuery();

    var qryDelete = new SubSonic.Query.Delete<product>()
        .Where(productTable.categoryIdColumn).IsEqualTo(categoryId);//Null reference exception here!!!!!!!!!

    batch.QueueForTransaction(qryDelete);

    qryDelete = new SubSonic.Query.Delete<category>()
        .Where(categoryTable.categoryIdColumn).IsEqualTo(categoryId);

    batch.QueueForTransaction(qryDelete);

    batch.ExecuteTransaction();

At runtime i got an exception when try to create a query. Any suggestions why?

Thanks in advance!