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 6733665
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:47:46+00:00 2026-05-26T10:47:46+00:00

I’m working on a desktop application that has generated code for database access and

  • 0

I’m working on a desktop application that has generated code for database access and uses static objects for user identification.

Now we need to expose some of the logic by webservice and we are looking for the least intrusive form to push the user information down the pipe to the database access classes.

What we came up with was to pass a delegate to the Insert / Update methods that looks like this:

public delegate string GetLogin();

public class BaseEntity : BaseNotifiableEntity, System.ComponentModel.IDataErrorInfo
{
    public GetLogin Login { get; set; }
    (...)
}

public static class BaseEntityHelper
{
    public static SqlCommand buildUpdateCommand(BaseEntity entity)
    {
        UpdateDefaultValues(entity, false);
        (...)
    }

    public static void UpdateDefaultValues(BaseEntity entity, bool affectCreationFields)
    {
        if (entity.Login == null && AppServer.RunningApplication.CurrentUser == null)
            throw new Exception("Something went wrong");

        (...)
    }
}

So in our logic will would have something like this:

    public class Service
    {
        T_DIST_Service record;
        (...)

        public bool Update(DataAccess.Base.GetLogin login)
        {
            record.Login = login;
            (...)
            record.Update();
        } 
    }

This of course involves changing a lot of methods in the application.
So i was wondering if there’s a seamless way to accomplish this using dependency injection (for example).

Probably some of you have already go down this road and have some insights to share.
Thank you for your time.

EDIT 1:
Using .NET

  • 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-26T10:47:47+00:00Added an answer on May 26, 2026 at 10:47 am

    On an architectural level it sounds like me that you are attempting to put logic in the data access layer that doesn’t belong there. A data access component should be nothing but an anti-corruption layer, so any logic should ideally be implemented in the calling layer.

    However, if you want a more immediate fix here and now, it would be most recommendable to use the built-in Thread.CurrentPrincipal Ambient Context.

    If you have special information that your user object must carry around, you can use a custom implementation of IPrincipal to create a custom User Context.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I've got a string that has curly quotes in it. I'd like to replace
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I have a French site that I want to parse, but am running into
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I need to clean up various Word 'smart' characters in user input, including but
public static bool CheckLogin(string Username, string Password, bool AutoLogin) { bool LoginSuccessful; // Trim
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti

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.