How to use WAQS? Split the generated code in many projects

7 reasons to use WAQS

WAQS documentation

 

In the last post, I presented you how to share specification methods between many edmx.

WAQS does not allow you to use many edmx in the same project.

So we need one project per model.

However, in this case, it is not great to duplicate WAQS Framework code (the code that does not depends on the Model) and it is not great to have many projects to host your different svc.

In my post How to use WAQS?, I used All option and I wrote that I will talk about it later. It’s time to do it.

You have 6 main options:

  • All: to generate all the code
  • WithoutGlobal: to generate the code without the config file, the global asax, the svc
  • WithoutFramework: to only generate the code that depends on the model
  • WithoutGlobalWithoutFramework: WithoutGlobal + WithoutFramework
  • FrameworkOnly: to only generate the Framework
  • GlobalOnly: to only generate config file, global asax and svc file

So in order to use many edmx, I recommend you to create n + 2 projects: one Class Library for the Framework, one for the Web Application and one Class Library per model.

Step by step

Create a Web Application project “WAQS.Server.Sample.Web”.

Add a new Class Library project in the solution “WAQS.Server.Framework”

Add a new Class Library project in the solution “WAQS.Server.MyModel” *

Add the two other projects in WAQS.Server.Sample.Web references *

Add WAQS.Server.Framework in WAQS.Server.MyModel references

Install WAQS Server NuGet package

Select WAQS.Server.Framework in NuGet Package Manager Console default project combo box.

Generate the code with this command:

WCFAsyncQueryableServicesServer "" FrameworkOnly

Add your edmx in WAQS.Server.MyModel project. (ex: Northwind.edmx) *

Select WAQS.Server.MyModel in NuGet Package Manager Console default project combo box. *

Generate the code with this command: *

WCFAsyncQueryableServicesServer "[…]\Northwind.edmx" WithoutGlobalWithoutFramework

Compile. *

Select WAQS.Server.Sample.Web in NuGet Package Manager Console default project combo box. *

Generate the code with this command: *

WCFAsyncQueryableServicesServer "[…]\Northwind.edmx" GlobalOnly

Then in the client, you can, do exactly the same including the svc path.

WCFAsyncQueryableServicesClient[WPF|PCL] "" "" FrameworkOnly

WCFAsyncQueryableServicesClient[WPF|PCL] "[…]\Northwind.edmx" "[…]\Northwind.svc" WithoutGlobalWithoutFramework *

WCFAsyncQueryableServicesClient[WPF|PCL] "[…]\Northwind.edmx" "[…]\Northwind.svc" GlobalOnly *

 

If you want to add a second model, repeat instructions that ends with a star.

 

Custom split

If you want a more detailed split, you can specify in the waqs config file which layer you want to generate.

For example, this is the default one generated in server with WithoutGlobalWithoutFramework option:

<DAL />
<DALInterfaces />
<Service Parallel="true" />
<ServiceInterfaces />
<WCFService />
<WCFServiceContract />
<Framework>
  <Common NamespaceName="WCFAsyncQueryableServices.Common" Generate="false" />
  <Specifications NamespaceName="WCFAsyncQueryableServices.Specifications" Generate="false" />
  <Entities NamespaceName="WCFAsyncQueryableServices.Entities" Generate="false" />
  <DAL NamespaceName="WCFAsyncQueryableServices.DAL" Generate="false" />
  <DALInterfaces NamespaceName="WCFAsyncQueryableServices.DAL.Interfaces" Generate="false" />
  <Expressions NamespaceName="WCFAsyncQueryableServices.SerializableExpressions"Generate="false" />
  <Service NamespaceName="WCFAsyncQueryableServices.Service" Generate="false" />
  <ServiceInterfaces NamespaceName="WCFAsyncQueryableServices.Service.Interfaces" Generate="false" />
  <WCFService NamespaceName="WCFAsyncQueryableServices.WCFService" Generate="false" />
  <WCFServiceContract NamespaceName="WCFAsyncQueryableServices.WCFService.Contract" Generate="false" />
</Framework>
This entry was posted in 16868. Bookmark the permalink.

Leave a Reply

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


*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>