Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7566973
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T14:32:49+00:00 2026-05-30T14:32:49+00:00

I just got off a small project using a WCF/REST Web Service that used

  • 0

I just got off a small project using a WCF/REST Web Service that used Entity Framework to access a database, apply some minor business logic, and pass the results to .NET Webforms front end. That worked pretty well, but the initial design was thrown together without a lot of time to investigate options, and now I’m being asked to do another very similar project. I have a bit more time now to see what’s out there and potentially do this project better than the first.

I want to find out if there are better ways to accomplish the a few things, specifically around passing objects back and forth between the web service and the front end.

For the first project, I created a shared library with class definitions that both the web service and the Website used. When a request came in to the web service, DB queries were performed, business logic was applied, and an object of one of the shared types was created and passed back in the web service response.

When the website got the response, it deserialized it to the appropriate shared object and went on its merry way.

It worked fine, but there was a lot of code that had to be written to define a shared object, then map the query results/business logic results to the shared object.

Is there a better way? Specifically what I’m looking for would be a way to:

  • automatically generate objects. (I’m not sure there is – it seems like I could autogenerate objects that were specifically mapped to database entities like tables or views (and indeed, that’s what the Entity Framework does) but what about objects that need to include non-DB info like stuff the business logic might add?)

  • remove the requirement for a shared library between the Web Service and the Website. I suspect this might exist, but I’m not even sure where to start on it.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T14:32:51+00:00Added an answer on May 30, 2026 at 2:32 pm

    I am working on a similar project and here is what I am doing (you can decide if it works for you or not).

    • View uses a UIModel
    • When a function is called, I pass my UIModel to a ServiceManager that maps the UIModel to a ServiceModel
    • The ServiceManager sends the ServiceModel to the service (I am using RestSharp to cut down on the mapping code)
    • My service receives the ServiceModel and immediately maps it to a BusinessModel (I am using ServiceStack to, again, cut down on the mapping code)
      • The service’s only job is to unwrap the service object and route it appropriately. This hides the internal details of my actual business layer. If that is not important to you, then your BusinessModel can be the same as you ServiceModel (and potentially the same as your database model)
    • My service sends the business model to a BusinessManager, which does any business logic and then creates a PersistenceModel to be passed into a RepositoryManager to be persisted
    • Then the whole process is reversed

    So, I end up with 4 models as summarized below:

    • UI has its own model
    • ServiceManager and Service share a model (which is also the point of the ServiceManager; to separate the concern of the UI from the service)
    • Business logic has its own model
    • Persistence logic has its own model

    This, as already mentioned above, allows for a separation of concerns. I can potentially change my persistence model without the need to change my contracts set in the service (which will be public). This will make it so that internal changes do not break external applications. You do run the risk of having to change all models, though.

    As to the boilerplate of mapping them all together, I am using AutoMapper. So, the code is not cluttered up with mappings due to AutoMapper, RestSharp, and ServiceStack. The code looks like code 🙂

    I am not sure if that entirely answers your question, but it does sound kind of like what you are explaining.

    UPDATE:

    This is to try to take the above and make it even more specific to the BDW’s ASP.NET solution:

    • Create a separate project that will only store your UIModels.
    • Reference that in your asp.net project, and expect to use that for any asp.net logic
    • Create a separate project that will only store your ServiceModels.
    • Whenever you need to call the Service, convert the data from your UIModel to your ServiceModel
      • This can be done inside your asp.net project. Or, you can create a new project that will take in the UI model and do the conversion and service call for you (that way your servicemodel does not have to be referenced in the asp.net portion)
    • Create another project that will call the service for you, using the ServiceModel
    • Now, you are in your service and per your comment, you can handle the rest
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I just got my site kicked off the server today and I think
Just got a question about generics, why doesn't this compile when using a generic
I just got Delphi 2009 and have previously read some articles about modifications that
I just got GeoDjango up and running on my development machine. Problem is that
I'm using php to build a small form that requires passing 2 variables for
I've got a small php web app I put together to automate some manual
I'm using Ubuntu Natty with PHP 5.3.8. I just got Gearman working on my
I've got a software suite that is based off of multiple libraries where: 1
I've got a small project which, when run in the Eclipse debugger, always seems
I've got a 16GB memory card off someone that won't load properly (asks to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.