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

  • Home
  • SEARCH
  • 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 8683727
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T22:07:17+00:00 2026-06-12T22:07:17+00:00

I’m working with self tracking entities on a n-tier application. So I have a

  • 0

I’m working with self tracking entities on a n-tier application. So I have a WCF service which provides the client access to the data layer and I find myself implementing a lot of the “same” functions corresponding with Getting some entities from my model, for example GetOrders, and after changing them in the client, a Save(Order order) or Save(TrackableCollection<Orders> orders) operation to persist the changes.

I’m wondering if there exists a T4 template that could build the basic interface, with Get/Save for single and collections of each entity and the corresponding service implementation from my model?

I’m aware that I could write my own T4 Template to generate this service, and I will probably do just that if I have to, but first I thought I’d ask the community if this effort exists already somewhere on the internet, is planned, is desired by others and/or is a totally stupid idea.

I did find this WCF Data Services Generator example, which is kind of on the right track.

Maybe something more suited to STEs using WCF in an n-tier solution is out there?

  • 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-06-12T22:07:19+00:00Added an answer on June 12, 2026 at 10:07 pm

    There are out there (more), but you’ll always need to customise.
    I’ve customised the simple templates found online, and in essence what it does is create the operation contracts, and web methods for visibility to win32 clients. Below is an excerpt:

    // I obtain anykeys by iterating through the entity keys:
    _anyKeys = string.Format("{0}{1} item.{2} == {3}_dto.{2}", _anyKeys, _and, key.ToString(), _double);
        // loop through all the entities:
        foreach (EntityType entity in Item1Collection.GetItems<EntityType>().OrderBy(e => e.Name))
        {
    
        /// <summary>
        /// <#=code.Escape(entity)#> Operation contracts - <#=code.Escape(entityName)#> 
        /// </summary>  
        [WebMethod]
        public bool Save<#=code.Escape(entity)#>(Dto<#=code.Escape(entity)#> _dto, int racID, string profile)
        {
            try
            {
                // Load the db
                using (<#=ContextName#> db = new <#=ContextName#>(EFUtils.GetEFConnectionString(profile, modelName)))
                {
                    // Check if item exists         
                    var exists = db.<#=code.Escape(entityName)#>.Any(item=> <#=code.Escape(_anyKeys)#>);
                    // convert to entity
                    var _entity = _dto.ToEntity();
                    if(exists)
                    {
                      // Attach the entity to the db
                      db.<#=code.Escape(entityName)#>.Attach(_entity);
                      // Change tracking
                      ChangeTracking<<#=code.Escape(entity)#>>(_dto.ModifiedProperties, db, _entity);
                    }
                    else
                    {
                      // New entity
                      db.<#=code.Escape(entityName)#>.Add(_entity);
                    }
                    // Save changes
                    return db.SaveChanges() > 0;
                }
            }
            catch(Exception ex)
            {               
                Global.LogMessageToFile(ex, string.Format("{0} - profile {1}, Save<#=code.Escape(entity)#>", racID, profile));
            }
            finally
            {       
            }
            return false;
        }
    
    
    // Then the interfaces
    #>
    #region <#=code.Escape(entity)#>
        /// <summary>
        /// <#=code.Escape(entity)#> Operation contracts - <#=code.Escape(entity.Name)#> 
        /// </summary>  
        [OperationContract]
        bool Save<#=code.Escape(entity)#>(Dto<#=code.Escape(entity)#> _dto, int racID, string profile);
        [OperationContract]
        bool Delete<#=code.Escape(entity)#>(<#=code.Escape(_keys)#>, int racID, string profile);
        [OperationContract]
        Dto<#=code.Escape(entity)#> Get<#=code.Escape(entity)#>(<#=code.Escape(_keys)#>, string  filterXml, int racID, string profile);
        [OperationContract]
        List<Dto<#=code.Escape(entity)#>> List<#=code.Escape(entityName)#>(string  filterXml, int racID, string profile);   
    #endregion
    <#+ 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have an autohotkey script which looks up a word in a bilingual dictionary
I have an array which has BIG numbers and small numbers in it. I
I have a text area in my form which accepts all possible characters from
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I have a small JavaScript validation script that validates inputs based on Regex. I
I am trying to understand how to use SyndicationItem to display feed which is

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.