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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T17:12:39+00:00 2026-06-07T17:12:39+00:00

I am implementing a service that lets users browse various objects, add new ones

  • 0

I am implementing a service that lets users browse various objects, add new ones then save them, which is a pretty basic functionality. The service is provided via WCF and uses EF4 code first to access data of a SQL Server Database.

However there is a catch: There are certain rules which are supposed to let only one user work on one object at a time, hence the lock edit unlock behaviour mentioned in the title.

So lets say there is a filter that says “records with a timestamp between date X and date Y”. Now a user locks this “filter” and is the only one who can add (note: not modify!) new records for the timerange between date X and date Y.

It is also worth noting that the filter is not a physical entity i can access since there are virtually unlimited possible filters to be had. A “select for update” / row lock is therefore not possible (i think!). Also, filters are only available in fixed timerange steps, so there is no overlapping of filters, though there is no limit on how far you can lock into the future (or past).

I have come up with a solution that works so far but i am not really happy with it. I prefer having the code in my service somewhere instead of implementing this in the database but any recommendation is welcome:

  • When a user requests a lock, i first check if there already is an object that conforms to the filter and has a “locked on” timestamp set. If there is, another lock is not possible. If not, i create a new record and save it to get a “handle” (some id) to this record for passing back to the client. Before i do that however i run the query again, and if i receive more than one record for the timerange that has the “locked on” timestamp set, the one with the e.g. highest id will count as the actual lock and all other records will be deleted. I dont think this is particularly clean so i dont really want to use it.

  • I also thought of using WCF operationcontract attributes to only allow a single call at any one time, but i dont like that either.

  • 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-07T17:12:42+00:00Added an answer on June 7, 2026 at 5:12 pm

    I’d recomend checking for an active filter either when a user attempts to select a filter, or when they attempt to save changes (selection makes for a better Ux). In order to determine the active filter you’ll need to make sure the time step is not already in use, which can easily be accomplished like this:

    public static class FilterMonitor
    {
    private static Dictionary steps = new Dictionary();

    public static bool CheckActiveAddIfNew(TimeStep step)
    {
        //Assumes synchronization logic
        bool isActive;
        if(!steps.TryGetValue(step, out isActive)
        {
           steps.Add(step, true);
           isActive = true;
        }
        return isActive;
    }
    
    public static bool ChangeFilter(TimeStep oldSetp, TimeStep newStep)
    {
       //Synchronization code
       bool ableToChange;
       if(!CheckActiveAddIfNew(newStep))
       {
           steps[newStep] = true;
           steps[oldStep] = false;
           ableToChange = true;
       }
    
       return ableToChange;
    }
    

    }

    Once a user is done with a filter they should release it and allow another user to acquire it if they want. This can be accomplished via something like the ChangeFilter method that only allows them to select the new filter if it has not already been selected by another user. This ensures that only one user can have access to a filter at any one time, preventing the case where multiple users will be adding/removing from the same filter.

    If however you need multiple users to access the same TimeRange but only want to allow a single user to add/remove records to that range, simply replace the bool in the Dictionary w/ a User object that maps to one and only one user. This changes the logic from being a simple active/Inactive filter to active & owned by User1/ Inactive. Obviously only User1 will be allowed to Add records to that range.

    Please let me know if you have any questions.

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

Sidebar

Related Questions

I'm implementing a Web service that returns a JSON-encoded payload. If the service call
I'm making an app that is requesting data from a Web Service (implementing Soap).
I'm well into implementing a REST service (on a Windows CE platform if that
we are implementing a new web service. The web service will be a store
I am implementing a WCF service that uses transaction propagation. The ASP .nET Security
We are implementing a SOA-architecture the Udi Dahan way, which means that services are
Implementing a web service that uses Transport-level security with WCF over HTTP is pretty
I'm currently implementing a service that uses WCF discovery and provides Discovery Endpoint and
I'm implementing a service that does REST calls for multiple applications. The results of
I'm implementing a REST web service that will be used from all around the

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.