Intro
[button link="http://northwind.mattjcowan.com" color="primary" target="_blank" size="info" title="See the Demo" icon_before="external-link"]See the Demo[/button] [button link="https://github.com/mattjcowan/LLBLGenPro_SS_Api_Razor_Templates" color="default" target="_blank" size="default" title="Get the Source" icon_before="github"]Get the Source[/button] In this post, we're going to explore building a generic RESTful api on top of a database with custom CRUD and query conventions, using the LLBLGen ORM and code generator, a ServiceStack service layer, and ServiceStack Razor html entity browser layer. This API and html entity browser can be generated on top of any database that LLBLGen supports (see here for supported database drivers). Inevitably, someone will ask, why not just use OData? OData is the route Microsoft is pushing for building RESTful data apis. OData is definitely worth learning and taking a look at, you will most likely use it in the future on some project, if you’re not already using it now. You can learn about OData here (http://www.odata.org/documentation) if it’s new to you, and browse a sample OData feed of Northwind here: http://services.odata.org/northwind/northwind.svc/. LLBLGen even supports OData. My personal opinion is, if OData meets your needs, use it! If you want complete control over your API however, and want the ability to plug in business rules, validation, authentication, authorization, generate UI components, impose some level of control over the queries against your database, want to easily be able to refactor your API, create accompanying documentation, and easily create similar APIs with similar logic and conventions over time across projects, you may want to consider the approach described in this post. (Sidebar: If you’re new to REST and/or interested in a slidedeck on REST, here’s a pretty good one). [box style="teal"] *New Updates (May 11, 2013)* Added new templates to support LLBLGen Typed Views and Typed Lists (for both LLBLGen 3.5 and LLBLGen 4.0). See new post here with more on this: RESTful Api and UI for Typed Views and Typed Lists with LLBLGen and ServiceStack. *New Updates (May 3, 2013)* Added new preset file compatible with LLBLGen V4. See Github. *New Updates (April 4, 2013)* See GitHub for update details. *New Updates (March 16, 2013)* Some new updates posted on the GitHub project on March 16th, 2013, see Change Log for details, including:- Clean xml output
- New "limit" parameter to limit the number of results returned (is trumped by paging)
- Deep fetching of related items (i.e.: products.orderdetails.order), including the ability to impose a limit of records returned on related items
- Restricting which fields are returned by a query on related items as well (i.e.: products.orderdetails.quantity)
- Introduced relation queries to filter a query based on related item filters (i.e.: all products supplied in japan sold between two dates)
Demo
JUST SHOW ME! Screenshots, demo link, and source on GitHub [one_half]

- Go here for the demo: http://northwind.mattjcowan.com
- Go here for the source (hosted on GitHub): https://github.com/mattjcowan/LLBLGenPro_SS_Api_Razor_Templates
RESTful Uri and Protocol Conventions
To discuss and demonstrate the usage of the auto-generated APIs, I’ll use the live demo above as illustration (which is also downloadable from GitHub). For the most part you’ll have to click on the links to see how the various formatted results look. For XML and JSON, in your AJAX apis, use the “accept” header, but you can force the format using the format parameter. We’ll use the “Category” and “Employee” entities throughout as samples for our queries. Parameters are always optional.Discoverable Entities
The entity API allows a user or application to discover the entities available in the system.Uri | Parameters | Protocol | Formats |
---|---|---|---|
{baseUri}/entities {baseUri}/entities/meta {baseUri}/entities?format=xml {baseUri}/entities?format=json | <none> | GET | [ html ] [ meta ] [ xml ] [ json ] |
Querying Entities
Once you have obtained your list of entities, you can browse a specific entity type using a “slug” version of the plural form of an entity name, or just follow the “href” property of the discoverable entity API above.Querying all instances of an entity type:
Uri | Parameters | Protocol | Formats |
---|---|---|---|
{baseUri}/{pluralizedEntityName} | See ‘advanced queries’ section | ||
{baseUri}/categories {baseUri}/categories/meta {baseUri}/categories?format=xml {baseUri}/categories?format=json | select={select} sort={sort} include={include} filter={filter} pageSize={pageSize} pageNumber={pageNumber} | GET | [ html ] [ meta ] [ xml ] [ json ] |
Querying a specific instance of an entity type using a primary key:
If the entity has multiple primary keys, just add them one after the other according to their index into the Uri.Uri | Parameters | Protocol | Formats |
---|---|---|---|
{baseUri}/{pluralizedEntityName}/{pk1}/{pk2} | |||
{baseUri}/categories/1 | select={select} include={include} | GET | [ meta ] [ xml ] [ json ] |
Using the filter parameter:{baseUri}/categories?filter=categoryid:eq:1 | [ html ] [ xml ] [ json ] |
Querying a specific instance of an entity type using unique constraints:
If the entity has unique constraints, they are discoverable in the field properties using the “categories/meta” convention. Unique constraints can be composed of multiple fields, just append each value for each field in the constraint to the URL. You can also use the filter API to achieve the same thing.Uri | Parameters | Protocol | Formats |
---|---|---|---|
{baseUri}/{pluralizedEntityName}/uc/{constraintName}/{value1}/{value2} | |||
{baseUri}/categories/uc/categoryname/{catname} | select={select} include={include} | GET | [ meta ] [ xml ] [ json ] |
Using the filter parameter:{baseUri}/categories?filter=categoryname:eq:{catname} | [ html ] [ xml ] [ json ] |
Creating/Updating/Deleting entities
A note about security. These create/update/delete methods are protected in the generated code with an Authenticate attribute requiring at minimum to be an authenticated user… You can add additional layers of security as needed with ServiceStack filter attributes on your data contracts, methods, and/or classes, or by plugging into the authorization and validation features built into LLBLGen Pro.Creating an entity:
To create an entity, simply POST your entity to the entity Uri.Uri | Parameters | Protocol | Formats |
---|---|---|---|
{baseUri}/{pluralizedEntityName} | |||
{baseUri}/customers | XML or JSON serialized version of your new entity | POST |
{ "address" : "Obere Str. 57", "city" : "Berlin", "companyName" : "Alfreds Futterkiste", "contactName" : "Maria Anders", "contactTitle" : "Sales Representative", "country" : "Germany", "customerCustomerDemos" : [ ], "customerId" : "ALFKI", "fax" : "030-0076545", "orders" : [ ], "phone" : "030-0074321", "postalCode" : "12209", "region" : "" }
Updating an entity:
To update an entity, simply POST your entity to the entity Uri.Uri | Parameters | Protocol | Formats |
---|---|---|---|
{baseUri}/{pluralizedEntityName}/{pk1}/{pk2} | |||
{baseUri}/categories/1 {baseUri}/categories/1/update | XML or JSON serialized version of your new entity | PUT POST |
Deleting an entity:
To delete an entity, simply POST your entity to the entity Uri.Uri | Parameters | Protocol | Formats |
---|---|---|---|
{baseUri}/{pluralizedEntityName}/{pk1}/{pk2} | |||
{baseUri}/categories/1 {baseUri}/categories/1/delete | XML or JSON serialized version of your new entity | DELETE POST |
Exceptions
Exceptions will typically come back formatted as follows (JSON syntax):{ "responseStatus" : { "errorCode" : "NullReferenceException", "errors" : [ ], "message" : "Object reference not set to an instance of an object.", "stackTrace" : "" } }
Advanced Queries
FILTER parameter: filtering entities
The syntax for filtering looks similar to Active Directory queries, but the AND clause is represented by a “^” character, and the OR clause is represented by a “|” character. A basic clause consists of three parts: {fieldName}:{filterOperator}:[{filterValue1},{filterValue2,…{filterValue(n)}] Here’s a sample clauses to filter categories according to their id: /categories?filter=categoryid:eq:1 Some operators accept arrays. This clause filters for all categories with either id = 1, 2, 3, or 4: /categories?filter=categoryid:eq:1,2,3,4 To specify multiple clauses in an AND structure, you would do that as follows: /categories?filter=(^(categoryid:eq:1,2,3,4)(categoryname:eq:condiments)) To specify the same clause in an OR structure, you would do that as follows: /categories?filter=(|(categoryid:eq:1,2,3,4)(categoryname:eq:condiments)) You can now combine the AND and OR structures to create compound clauses. This example fetches (all categories with id = 1, 2, 3, or 4 AND where the category name is “condiments”) OR (where the description contains the word ‘and’) /categories?filter=(|(^(categoryid:eq:1,2,3,4)(categoryname:eq:condiments))(description:lk:"*and*")) The generated API supports the following operators (with examples):SELECT parameter: selecting specific fields
You can ask the api for specific fields instead of the entire object graph, which can considerably improve performance. Categories have embedded images, so we wouldn’t want to constantly be returning all that data. So, in this example, we will fetch all categories restricting the query to only the category name and the description (the PK of the entity is always returned!). Sample select query: /categories?select=categoryname,description [ HTML version | JSON version | XML version ]INCLUDE parameter: including related items
You can ask the api to return related objects upfront, which improves performance by preventing you from having to come back and get the objects iteratively. In this example, we’ll return the “Reports To” and “Employee Territory” fields as a single GET for the employee with ID = 1. As you can see also in the two results below, querying using a filter parameter gives you a response as part of an array, whereas, querying the specific entity gives you the entity directly (not within an array). /employees?filter=employeeid:eq:1&include=reportsto,employeeterritories [ HTML version | JSON version | XML version ] OR /employees/1?include=reportsto,employeeterritories [ META version | JSON version | XML version ]RELATION parameter: querying on related items
Support for querying on related items is still in the works. LLBLGen provides not only a deep-fetch api, but also a very flexible API to construct almost any SQL you want, including creating filters on items N deep by traversing relationships in the database. The creators of LLBLGen have spent considerable time figuring out how to optimize the SQL for performance, it’s trustworthy. This feature is one of the big reasons I prefer LLBLGen over the Entity Framework. I’ll try to add this as a feature to this generated API in the near future.PAGING parameters: paging data
Unless otherwise specified, by default, paging is set to 10 items at a time. In this example we’ll query for the 2nd page of customer data using a page size of 5. The HTML interface uses it’s own paging mechanism, so this example showcases paging using the JSON and XML formats. /customers?pageSize=5&pageNumber=2 [ JSON version | XML version ] One thing you’ll notice is the “Paging” object that is returned as part of the response. The paging object has everything that’s needed to construct good paging capabilities on the client-side.{ ..., "paging" : { "firstItemOnPage" : 6, "hasNextPage" : true, "hasPreviousPage" : true, "isFirstPage" : false, "isLastPage" : false, "lastItemOnPage" : 10, "pageCount" : 19, "pageNumber" : 2, "pageSize" : 5, "totalCount" : 91 } }
SELECT parameter: selecting specific fields
You can easily sort your data, and sort on multiple fields as well. In this example, we will sort customer data by country in ascending order, city in ascending order, then company name in descending order. If you don’t specify a sort operator for a field, it’s assumed to be ‘ascending’. /customers?sort=country,city:asc,companyname:desc [ JSON version | XML version ]Using C# and the ServiceStack Client to call the Query service(s)
Check some of the basic unit tests for samples, it's ServiceStack out-of-the-box: ConnectivityTests.cs, BasicQueryTests.csUsing javascript / jQuery to call the Query service(s)
There is nothing fancy going on here. Simply use the standard $.getJSON() or *.ajax() jQuery apis, they work out of the box.Generating the Api
You can follow along with this tutorial simply by downloading the LLBLGen templates from GitHub, and reproducing the steps I’m going over in this section.
Step 1: create your model in LLBLGen
See here for documentation on how to use the LLBLGen designer: http://www.llblgen.com/documentation/3.5/Designer/hh_start.htm.
When creating your model, make sure to use the “LLBLGen Pro Runtime Framework”.
The templates that were put together to create this API utilize the LLBLGen adapter strategy for talking back and forth to the database. The LLBLGen adapter strategy works for almost every relational database out there, and performs great.This is what my model looks like over the Northwind database, and as used in the examples in this blog post.

Step 2: add the ServiceStack template files
Unzip the template files into the same directory as your llblgen project file… Something like this:
With the templates now downloaded, edit your project settings to recognize the templates, by going to “Project >> Settings”
Press OK. Then press the "Refresh code generation metadata button" in the toolbar. Now when you go to the menus “Window » Show Template Bindings Viewer”, you should see the “MJC.TemplateBindings.ServiceStack” option in the template bindings drop down. This is where you can further extend, copy and/or modify the templates to enhance and refine your code-generated api according to your needs if you want.


Step 3: generate the code
To generate the code, go to Project » Generate source code. In the dialog window that pops up, under “Selected preset”, make sure you pick the “MJC.Presets.Adapter.ServiceStack” option. If you don’t see this option, repeat step 2 (remember to save your project file, you may even have to close and re-open the project file).
Then, press “Start generator (Normal)”

Step 4: open the solution in visual studio
In visual studio, create an empty solution and add the projects to it.
For the solution to compile, you need LLBLGen obviously in your GAC, and you also need the ServiceStack assemblies. The recommended way to add ServiceStack is to use Nuget (see here for information on Nuget if it’s new to you). Save your solution, and open your command prompt (or install the assemblies with the Nuget dialog, whatever your preference is) and install ServiceStack into the following projects (as follows):
nuget update -self mkdir packages nuget install .\ServiceGeneric\packages.config -OutputDirectory .\packages nuget install .\ServiceSpecific\packages.config -OutputDirectory .\packages nuget install .\Hosts\ConsoleHost\packages.config -OutputDirectory .\packagesMake sure the solution compiles, and now you’re ready to fire it up. The ConsoleHost is a sample self-hosted application which hosts the ServiceStack services on top of LLBLGen. You can host the services in a variety of ways (Windows Service, Console, IIS, and more…), refer to the extensive ServiceStack documentation to learn how to host ServiceStack according to your needs (feel free to comment and/or contact me if you are having issues with this).
Step 5: run it
Before you run the application, go to the app.config file in your ConsoleHost project and make sure the "ApiDbConnectionString” in the connection string section has the right value.Open a command prompt, CD to the bin\debug directory of the ConsoleHost project and start the server.
The console will tell you what port to go to in your browser to access the api. Now open your browser to that URL, in my case above it’s http://localhost:1337.

I’ve been running Matt’s templates with a team of 6 developers for almost a year. These templates have saved us untold hours of work. They have also helped me to get a group of people w different experience levels and backgrounds onto the same page – into a cohesive productive team.
Hi, we have na already working LLBLGen Project that uses SD.Presents.SelfServicing.TwoClasses, with some little changes ( basicaly, no pluralize or singularize and including generation of Validators ). I wish to know if there’s any way to use the provided templates for REst api generation with my current template configuration ( not Adapter ).
Thanks!
Hi Leandro, unfortunately, these templates wouldn’t work for your scenario. Feel free to re-work them if you feel up to it.
Ok. Thanks Matt!
I’ll analyze those templates and check how time expensive will be to adapt them for this project’s needs. In case I opt for adapt I’ll send the code here, for others with same needs.
Thanks again!
Hi Matt,
awesome work! But I’m struggling with the creation of an own project. To clarify: in LLBLGen there are 2 available Presets: “…ServiceStack” and “…ServiceStack.V4”. What does V4 stand for? v4 of LLBLGen or .Net version 4.0?
I tested some combinations from above 😉 I generate the source code, add the projects to my solution. Add ServiceStack to the projects and try to compile. I always end up with 2 error messages:
‘ServiceStack.ServiceHost.IHttpResponse’ does not contain a definition for ‘EndHttpRequest’ and no extension method ‘EndHttpRequest’ accepting a first argument of type ‘ServiceStack.ServiceHost.IHttpResponse’ could be found (are you missing a using directive or an assembly reference?) \ServiceGeneric\Razor\CmsRazorHandler.cs 52 25
and:
Error 5 The type ‘System.Web.Razor.RazorEngineHost’ is defined in an assembly that is not referenced. You must add a reference to assembly ‘System.Web.Razor.Unofficial, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null’. \ServiceGeneric\Razor\CmsRazorPageResolver.cs 137 13
I found the System.Web.Razor.Unofficial package but it installed via nuget with version 2.0.2.
It would be SO GREAT if you could write another post describing from how to get from start in LLBLGen to finish with usable services accessable via /api/… routes (beside a mvc app). Your templates would be such an amazing time saver that I really hate myself for not getting these things to run 🙁
The Nuget dependency stuff can take a little manual reconciliation, I probably should just jump in and package this in Nuget to get this up and running quickly, maybe that would make things easier.
For now, V4 is what you want if you’re using LLBLGen V4. I probably will deprecate the non-V4 preset at some point in the near future, it seems most of those that have contacted me and are using these templates have upgraded now and are on V4 of LLBLGen. If you want, I can point you to a download link of a fully working VS 2012 solution as well so that you can compare it with what you have (let me know if you’d like that). You can also compare your packages.config with mine and maybe try reconciling the differences (https://github.com/mattjcowan/LLBLGenPro_SS_Api_Razor_Templates/blob/master/src_v4/Hosts/ConsoleHost/packages.config). One great thing about LLBLGen, is once you have your solution running with your generated code, you are able to regenerate without issues, which makes iterative dev easy.
Dear Matt, thank you for your quick response. A fully working project would be a good starting point.
Here you go … Let me know if you have any issues running it … You’ll need the Northwind database (SQL provided to create that database).
Thank you Matt! I’ll take a look at it over the weekend.
Hi it seems I am part of that edge case mention in one of the posts
Name cannot begin with the ‘[‘ character, hexadecimal value 0x5B. Line 36, position 18.
LLBLGen Pro version 4.0. Build May 15th, 2013
Hey Jaco, thanks for sending me your llblgen project file. I sent it back to you with a few minor edits and a sample generated solution that works. Seems it was mostly about selecting the correct preset, the project seemed to be pointing to the preset for the v3.5 version, instead of “MJC.Presets.Adapter.ServiceStack.V4.preset”. Hope that gets you on your way.
Hi Matt,
I have received it and it works perfectly 🙂 Thank you for helping me during the night I do appreciate the extra mile you have put in to resolve my issues.
And it is as you said, I totally choose the wrong Adapter preset. I almost chose v4 the first time around but I am conservative in my approach and don’t assume things without reading up 🙂 It would have taken me quite a lot of reading to realize my own mistake.
I will keep you updated.
PS: You mention in the mailing list in regards to question relating to crm and mvc… that even tho SPA is currently hip, that MVC might still have a place by serving a protal of mini spas…
Is this something you have been looking at ? Or just and Idea that you have pondered about in the past ?
It’s an idea/concept I’m exploring for 2 separate projects I have in mind.
This looks very nice. However I’m getting the following error when generating using this template:
Name cannot begin with the ‘[‘ character,
Hey Trevor, unfortunately, that’s not a lot to go on. Others are using the templates successfully, so maybe it’s an edge case of some kind. If you’re able to try the sample Northwind project, see if you still get the error with that one. Be glad to help you further if you can’t get through this, hit me up using the contact us page, and/or enter an issue on GitHub.
OK, I’ll see if I can give you more details. Basically I was following your steps on my own database, not Northwind. I’ll see if I can get further along.
Somebody else had your issue, and it seemed related to the preset being used during code-generation. Can you make sure you’re using the “MJC.Presets.Adapter.ServiceStack.V4.preset” preset?
Nice! Thanks for the update. Any thoughts on how to manage data changes without re-generating an entire codebase?
Hey KC, schema changes would require re-generating the codebase. What data changes in particular are you wanting to make without requiring re-generating the codebase? As far as I know, right now, there isn’t a way to just re-generate a few files at a time in LLBLGen. What you can do, is create a batch file and use the command line tools LLBLGen provides to regen, which can save you some time when you’re just adding tables and columns in the DB and want to quickly get your solution up to speed, without jumping in and out of the designer.
I posted an update on GitHub which now includes:
– Validation
– User Regions to extend the code
– Lots of partial methods strategically placed to leverage with partial classes as needed
See the documentation at the GitHub Project.
I think this will help with being able to easily extend the generated code as-needed.
Feel free to post issues on GitHub (including enhancement recommendations, etc…).
Cheers,
Matt
Code generated fluent validations would be great for simple stuff (like field type, length etc..). But what I’m really looking for is either code regions or partial classes for adding complex business logic.
My use case is pretty complex so often adding a resource to one table needs to modify several other tables too. Validation rules for one resource also may involve several different tables. It’s not the sort of logic that can be code generated–but I’d like to put it behind the web service so that I don’t have to implement (and maintain) it on every platform.
These templates are a really awesome starting point for me.
I am very new to REST/WEB/MVC etc. Your post save me lightyears. Thanks for this fantastic post.
(Like scotru ask you) do you have any suggestion about authentication & authorization?
I think the way to extend the methods will be to add zones in the templates so that you can add stuff to the generated code without it getting overwritten, and/or adding some settings in the LLBLGen designer to accommodate for desired attributes and/or validators. I’ll try to look into it this week. The web host project that’s on GitHub does have an example also of authentication if you haven’t seen it yet which uses the ServiceStack BasicAuthProvider plugin here, and uses the Authenticate attribute for Create/Update/Delete here for example. I’ll get an update out this week.
Got my database up and going with this tonight–total time about 3 hours. Very nice! Main problems I encountered were due to my own dumb database naming: 1) field names can’t match table names since DTO data members can’t match class names, and 2) having tables with the same name as a BCL namespace is a bad idea!
I think the template: ss_svc_AssemblyInfo.template has a URL at the top that shouldn’t be there.
For some reason the HTML display isn’t showing up correctly for me: all strings display as blank (I’ll look into that later), integers look ok. But the XML and JSON looks great!
I’m looking forward to playing with this more. Do you have any advice on how/where to inject business logic and validation rules (I’m pretty new to ServiceStack.NET)?
Thanks!
Nice… Thanks for the heads up on that file, now fixed. I’ll think about the business logic and validation, maybe we use some code-generated fluent validators.
Great updates! I’m still super excited about this. Quick question: you mention embedding business rules, validation, authentication & authorization. Where would you picture being the best place within the system to inject this kind of use specific code?
Just wanted to leave a comment here for anyone else interested that I was able to get jsonp working for cross-domain requests (hosting the html view on a different site) by creating a Get method for the *DataTableRequest, changing the route verbs to “GET,POST” and modifying the scripts.js datatable to request the jsonp datatype (see here: http://www.datatables.net/release-datatables/examples/server_side/jsonp.html)
Looking forward to seeing the relation querying stuff.
Thanks again.
Very nice KC. I’ll post an update once I get the relations in there. I’m currently adding unit/integration tests to the checked in source to validate and demo how to call the generated services from a C# client (pretty much ServiceStack out of the box, no surprises there). Subpath prefetches, and relations next. Then, time willing, a couple other things in store too for LLBLGeners to enhance the generated apis and views.
Hey KC, got some more updates for you, see the src and templates on GitHub. Keep your eyes on that repo as I’ll keep a change log going on the frontpage there for now, including some relational query filters and a fix to the xml formatting you commented about.
Nice article!
You’ll now have to update your favorite libraries list to include servicestack!
Yes indeed, I’ll make sure to do that. That list is a few years old, oh my! 🙂
Hi Matt,
Thanks for this absolutely fantastic demo that takes advantage of ServiceStack’s design showing how you can enhance existing REST-ful services to provide a full-featured HTML website editing experience. It’s a great example of the type of development that ServiceStack is trying to encourage.
Just wanted to leave a not for some readers on why ServiceStack recommends the use of special-purposed DTOs, since there have been some comments about it:
http://stackoverflow.com/a/15369736/85785
Thanks Demis. Also, in keeping with those recommendations, the generated code creates a separate class library for the services and the service DTOs that is completely decoupled from the rest of the project. That way, LLBLGen is decoupled from ServiceStack, and ServiceStack decoupled from LLBLGen. That integration is pieced together in the ServiceStack IoC container using service repository implementations. That way, only the assembly with the service DTOs is needed on the client to work with the entities.
Thanks KC for identifying 2 issues that we were able to quickly fix: (1) carriage return conversion issue for LLBLGen template files to/from GitHub, (2) a namespace error in one of the template files.
Couple tips for those wanting to get this running with their own database:
1) Use the LLBLGen v3.5 designer in .net 4.0 mode (one of the templates is using System.Data.Entity.Design, i may refactor that later to avoid this constraint)
2) When generating the templates, if you get an access denied error, try running the designer as administrator
3) Make sure every table has a primary key (it can be a PK with multiple fields, but there has to be a PK at this time)
Got it working with my own database with the help of Matt. Thanks, you rock. This is awesome.
Trying this myself now, getting an error while generating source code…
MJC.Presents.Adapter.ServiceStack.PagedListClassGenerator (SD.Tasks.Base.ConsumeLptTemplate)::Executing task.
MJC.Presents.Adapter.ServiceStack.PagedListClassGenerator (SD.Tasks.Base.ConsumeLptTemplate)::Using class ‘SD.LLBLGen.Pro.LptParser.DotNetTemplateEngine’ in assembly ‘SD.LLBLGen.Pro.LptParser.dll’.
Source code Generation: Complication of templates into file ‘C:\Users\Administrator\AppData\Local\Temp\aaaaaaaaaaaaaaaaaaaa\templateSource.cs’ failed with 209 errors.
Source code Generation: Compile Error CS1010 in file C:\Users\Administrator\AppData\Local\Temp\aaaaaaaaaaaaaaaaaaaa\templateSource.cs, at (762, 24): Newline in constant
Any ideas? Thanks!
It’s hard to tell from that, as the templateSource.cs file is an aggregate of the compiled templates. If you look at line 762 of the templateSource.cs, it might shed more light on the error.
Hit me up on google chat if you want (matthewj.cowan)…
This is very cool. Question though – what is with the odd xml names?
For example http://northwind.mattjcowan.com/categories
Hmm, I didn’t pay too much attention to that, as I was focusing more on the json stuff. But yeah, that’s ugly 🙂
I imagine it’s because I’m just tagging the dtos as serializable instead of using datacontract attributes. I’ll have to look into ways to clean that up. Good catch!
Ah, right, good point on refreshing, I’ll update the post.
Yes, I opted for DTOs to use the ServiceStack serializer, slight trade-off, but you’re right, that’s another approach for sure.
Awesome work!
btw:
“Press OK, and to make sure the folders take, save your project file, and re-open it”
you don’t have to do that. Just press the tools-> Refresh code generation metadata button (also in the toolbar). 🙂
I see you opted for DTOs. Is this due to the JSon serializer in ServiceStack? Because our entities do serialize to json just fine with json.net (but it’s minor, really. It’s generated, so who cares :))