Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 4 > BOOK: Beginning ASP.NET 4 : in C# and VB
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Beginning ASP.NET 4 : in C# and VB
This is the forum to discuss the Wrox book Beginning ASP.NET 4: in C# and VB by Imar Spaanjaars; ISBN: 9780470502211
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 4 : in C# and VB section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 4th, 2013, 09:56 AM
Registered User
Points: 39, Level: 1
Points: 39, Level: 1 Points: 39, Level: 1 Points: 39, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2012
Posts: 9
Thanks: 3
Thanked 0 Times in 0 Posts
Default How to use addHours function with Linq?

Hi, I am using the modified version of the content of the book and i use "Events" instead of "Genres" and the "Comments" as is. Although i have my DB engine resides in the USA hence we have 8 hours of time differences and basically i want to correct this time differences by adding "8hrs" to the comments "CreateDateTime" column when the user adds his/her comment. Since we use Linq and i don't how to achieve this! Or Can we use TimeZoneInfo convertTime function of conversion?? Any help will be appreciated. Thanks!
Here is my linq anonym type as follows,
where a.Authorized == true
select new
{
a.Id,
a.VenueName,
a.EventType,
a.Date,
a.StartTime,
a.EndTime,
a.Address,
a.Phone,
a.Reviews(This is my Comments where i stuck!!!)
};
Reply With Quote
  #2 (permalink)  
Old April 4th, 2013, 02:40 PM
Imar's Avatar
Wrox Author
Points: 72,022, Level: 100
Points: 72,022, Level: 100 Points: 72,022, Level: 100 Points: 72,022, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,076
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

If you want to change it just when you display it, you can query the data first, and then loop over it. Depending on the resultset, you may need a double loop:

Code:
foreach (Event event in events)
{
  foreach(Review review on evemt.Reviews)
  {
         review.CreateDateTime = review.CreateDateTime.AddHours(8);
     }
}
Alternatively, you can do this when you insert the data, so the data is in a more consistent state in the database.

Hope this hepls,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
Reply With Quote
The Following User Says Thank You to Imar For This Useful Post:
master777 (April 4th, 2013)
  #3 (permalink)  
Old April 4th, 2013, 06:16 PM
Registered User
Points: 39, Level: 1
Points: 39, Level: 1 Points: 39, Level: 1 Points: 39, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2012
Posts: 9
Thanks: 3
Thanked 0 Times in 0 Posts
Default Excellent! Thanks

I have been searching for this approach for days! may be like 2 weeks. So Thank you ever so much! Excellent!!!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
LINQ or T-SQL? DennisE ASP.NET 4 General Discussion 2 October 29th, 2011 11:36 AM
LINQ to EF and LINQ to SQL sophia BOOK: Beginning ASP.NET 4 : in C# and VB 1 October 19th, 2011 12:16 PM
Linq Problem sridharnetha C# 2005 1 December 29th, 2009 07:31 AM
LINQ vaibhavgoe LINQ 4 December 21st, 2009 03:49 PM
LINQ Tutorial manish .NET Framework 3.5 1 August 13th, 2009 01:07 PM



All times are GMT -4. The time now is 05:53 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.