WAQS: Specifications factorization

7 reasons to use WAQS

WAQS documentation


In some cases we want to factorize one part of specifications methods.

For example, imagine that we want to extract InvoiceDetail creation in our MakeInvoice method.

However, we don’t want to have a service method  MakeInvoiceDetail.

For this case, WAQS uses a convention: defining the method internal instead of public.

public static Invoice MakeInvoice(this Order o, INorthwindWAQSEntities context)
    var invoice = new Invoice { OrderId = o.Id, CustomerId = o.CustomerId, Total = GetTotal(o), Dicount = GetDiscount(o) };
    if (o.Customer != null)
        invoice.CustomerCompanyName = o.Customer.CompanyName;
        invoice.CustomerContactName = o.Customer.ContactName;
    foreach (var od in o.OrderDetails)
    return invoice;

internal static InvoiceDetail MakeInvoiceDetail(this OrderDetail od)
    return new InvoiceDetail { OrderDetailId = od.Id, Quantity = od.Quantity, UnitPrice = od.UnitPrice, Discount = od.Discount, Amount = GetAmount(od) };

Then the generated code will be public but it’s just a way to specify to WAQS that the code is neither a Calculated Property, nor a Validation method, nor a metadata definition nor a service method.

This entry was posted in 16868. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *