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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T12:20:43+00:00 2026-05-11T12:20:43+00:00

I am working on a web service for creating, changing and removing hotel reservations

  • 0

I am working on a web service for creating, changing and removing hotel reservations (bookings). One booking can contain several stays (a stay is a link between a room, the services ordered, etc.). Each stay has it’s own time period, so you can create 3 stays in the same booking, for 3 different weeks.

My problem arises when bookings need to be changed. The input is the booking id (as seen above) as well as the new data on the wanted stays. So if the original stays were 2 single rooms and 1 double room, each with their own start and end date, and the customer wished to change one of the single rooms to a double room, he would send: 1 single, 2 double, and it’s up to me to figure out what has changed (this is not going to change, so I’m afraid any solutions suggesting to change this is out).

I use LINQ to pick out the current stays and set them for deletion

var oldStays = (from stay in persistentStorage.DataContext.Stays                  where stays.booking_id == bookingId                  select stay); persistentStorage.DataContext.Stays.DeleteAllOnSubmit(oldStays); 

Before I can delete them, however, I need to make sure that there is available rooms for the new stays. An easy way out would be if LINQ automatically assumes these records as deleted when making new queries (meaning I would not have to worry about dates, existing rooms, etc.). If that is the case, the problem is already solved.

If not, I need some way of checking for new available reservations while at the same time ignoring stays that have not changed (in the above case, I would only need to check if a double room was available in the given period, since the other double and single are already booked). Is there some smart way LINQ can assist in this, and if so, how?

  • 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. 2026-05-11T12:20:44+00:00Added an answer on May 11, 2026 at 12:20 pm

    You should be able to get the intended behaviour by using transactions:

    • create a transaction
    • delete your bookings
    • check if the new rooms are available and book them
    • if everything is ok, commit
    • otherwise rollback the transaction

    EDIT – Sample (using SQL transaction, you could also use a TransactionContext):

    try {   persistentStorage.DataContext.Transaction=persistentStorage.DataContext.Connection.BeginTransaction();    var oldStays = (from stay in persistentStorage.DataContext.Stays                  where stays.booking_id == bookingId                  select stay);   persistentStorage.DataContext.Stays.DeleteAllOnSubmit(oldStays);   persistentStorage.DataContext.SubmitChanges();    // do you select/insert/etc.    if (ok)     persistentStorage.DataContext.Transaction.Commit(); } finally {   if (persistentStorage.DataContext.Transaction!=null) persistentStorage.DataContext.Transaction.Dispose();   persistentStorage.DataContext.Transaction=null; } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am working on project in which we are creating a web service that
I'm working on creating a WCF web service that communicates via JSON. I got
I've been working off an example (http://bdoughan.blogspot.com/2010/08/creating-restful-web-service-part-45.html) and I've been debugging some issues and
We are working on creating an installation package for a WCF-based web service. The
I'm working on a web service installation. One of the things I need to
I'm working on a web service at the moment and there is the potential
I'm working on a Web service in Django, and I need to model a
I am working on a web service project using gsoap. I am new to
I'm working with a web service that will give me values like: var text
I'm working on a RESTful web service in Java. I need a good way

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.