Is it possible to Pivot data using LINQ?

Is it possible to Pivot data using LINQ?

I am new to LINQ, but I am wondering if it is possible to use LINQ to pivot data from the following layout:CustID | OrderDate | Qty1 | 1/1/2008 | 1002 | 1/2/2008 | 2001 | 2/2/2008 | 3502 | 2/28/2008 | 2211 | 3/12

Why saving changes to a database fails?

Why saving changes to a database fails?

I have following C# code in a console application.Whenever I debug the application and run the query1 (which inserts a new value into the database) and then run query2 (which displays all the entries in the database), I can see the new entr

window.close and self.close do not close the window in Chrome

window.close and self.close do not close the window in Chrome

The issue is that when I invoke window.close() or self.close() it doesn't close the window. Now there seems to be a belief that in Chrome you can't close by script any window that is not script created. That is patently false but regardless

Visual Studio 2010: Why aren't key combinations available?

Visual Studio 2010: Why aren't key combinations available?

I am trying to use VS 2010 for writing C. Frequently, I try to use a hotkey combination, and I get an error message of the form: The key combination (key, key) is bound to command (Command) which is not currently available.Why is this? E

What's the Best Way to Add One Item to an IEnumerable?

What's the Best Way to Add One Item to an IEnumerable?

Here's how I would add one item to an IEnumerable object://Some IEnumerable objectIEnumerable arr = new string[] { "ABC", "DEF", "GHI" };//Add one itemarr = arr.Concat(new string[] { "JKL" });This is awkward. I don't see a method called so

Should you avoid static classes?

Should you avoid static classes?

are static classes considered bad practice? I read an article about this a couple days ago (can't find it, sorry) which basically said that having static classes (especially those 'helper' classes) are typically a sign of bad code. Is this

Using Html.RenderPartial() in ascx files

Using Html.RenderPartial() in ascx files

I'm trying to use Html.RenderPartial in acsx fileand I'm getting an error: Compiler Error Message: CS1973: 'System.Web.Mvc.HtmlHelper' has no applicable method named 'RenderPartial' but appears to have an extension method by that name. E

Why doesn't C have binary literals?

Why doesn't C have binary literals?

I am frequently wishing I could do something like this in c:val1 &= 0b00001111; //clear high nibbleval2 |= 0b01000000; //set bit 7val3 &= ~0b00010000; //clear bit 5Having this syntax seems like an incredibly useful addition to C with no dow

M4V Mimetype - video/mp4 or video/m4v?

M4V Mimetype - video/mp4 or video/m4v?

I am serving a video via the HTML5 video element. I'm finding conflicting information about the appropriate MIME type for m4v video. Most demos set the type attribute to video/mp4 in the source tag in the markup. Some articles I've read ind

Is BIGINT(8) the largest integer mysql can store?

Is BIGINT(8) the largest integer mysql can store?

I've got some numbers that is now larger than INT can handle.This is a bit embarassing, but I honestly don't know exactly what the BIGINT(8) means. Is the 8 in that the max bit value or the max length?So BIGINT(1) can only be one digit? Or

Is there anyway to get ID3 metadata from an MP3 or Vorbis comments from Ogg via the HTML5 audio elem

Is there anyway to get ID3 metadata from an MP3 or Vorbis comments from Ogg via the HTML5 audio elem

Mozilla Developer Center's HTML5 media guide describes an event for audio and video elements called "loadedmetadata". Is there anyway to get the metadata for files? I am writing an HTML5 extension for Google Chrome and I don't know what the

Add a Windows Shell context menu entry for a specific extension (not file type)

Add a Windows Shell context menu entry for a specific extension (not file type)

To add a Windows shell context menu, let's say for .txt files - if the .txt extension in HKEY_CLASSES_ROOT (or in HKEY_CURRENT_USER\Software\Classes, doesn't really matter) has the default value (file type) txtfile - you add the command to

Uploaded docx files turning into zip

Uploaded docx files turning into zip

I am currently using symfony 1.4 and would like to allow users to upload Microsoft Word docx files. Using the sfWidgetFormInputFile widget and sfValidatorFile below users are able to select and successfully upload their docx files using a

How do I limit which countries can view my website ( PHP )

How do I limit which countries can view my website ( PHP )

In there an easy way to do this in PHP. I want to make sure that only web requests from certain countries are able to access my website.Any ideas? 1:Use an IP geolocation database (some are free) and $_SERVER["REMOTE_ADDR"] to get the vi

Mercurial: Remove file from all changesets

Mercurial: Remove file from all changesets

I understand how to remove an entire changeset from history but it's not clear how to remove a subset instead.For example, how do I remove all DLL files from an existing changeset while leaving the source-code alone? 1:Because the revisi

linux mail < file.log has Content-Type: application/octet-stream (a noname attachment in Gmail)

linux mail < file.log has Content-Type: application/octet-stream (a noname attachment in Gmail)

I've been using mail -s "here is a log file" "[email protected]" Which used to come through with headers:User-Agent: Heirloom mailx 12.4 7/29/08MIME-Version: 1.0Content-Type: text/plain; charset=us-asciiContent-Transfer-Encoding: 7bitBut

Check for framework's existence at compile time?

Check for framework's existence at compile time?

I'm working on an open-source project that can optionally use a closed-source framework. If the closed-source framework is included in the project, there will be additional functionality. But if the framework isn't included in the project,

In C#, how to check whether a string contains an integer?

In C#, how to check whether a string contains an integer?

I just want to know, whether a String variable contains a parsable positive integer value. I do NOT want to parse the value right now. Currently I am doing:int parsedId;if ( (String.IsNullOrEmpty(myStringVariable) || (!uint.TryParse(m

How do you enforce lowercase routing in ASP.NET Core MVC 6?

How do you enforce lowercase routing in ASP.NET Core MVC 6?

In ASP.NET 4 this was as easy as routes.LowercaseUrls = true; in the RegisterRoutes handler for the app.I cannot find an equivalent in ASP.NET Core MVC6 for achieving this. I'd think it would be here:app.UseMvc(configureRoutes =>{ config

Is the charset meta tag required with HTML5?

Is the charset meta tag required with HTML5?

The W3C "HTML5 differences from HTML4" working draft states: For the HTML syntax, authors are required to declare the character encoding.What does "required" mean? Obviously, a browser will still render HTML5 without the charset meta tag.

How to get current orientation of device programmatically in iOS 6?

How to get current orientation of device programmatically in iOS 6?

I have developed an iOS App and tested it on iOS6 device. While testing, I realized that my App is not responding to Orientation changes as expected.Here is my Code:// Autorotation (iOS >= 6.0)- (BOOL) shouldAutorotate{ return NO;}- (NSU

Are all functions in C/C++ assumed to return?

Are all functions in C/C++ assumed to return?

I was reading this paper on undefined behaviour and one of the example "optimisations" looks highly dubious:if (arg2 == 0) ereport(ERROR, (errcode(ERRCODE_DIVISION_BY_ZERO), errmsg("division by zero")));/* No overflow

“call to undefined function imagecreatetruecolor” error in PHP & pChart

“call to undefined function imagecreatetruecolor” error in PHP & pChart

I am trying to integrate "pChart" with my PHP code. When I am trying to run the samples it gives me an error stating call to undefined function imagecreatetruecolor. The suggestion solution was to load this dll "php_gd2.dll" so I have uncom

Last day of the month in .NET

Last day of the month in .NET

Normally I use the below code, but is there a better way?lastOfMonth = new DateTime(Now.Year, Now.Month, 1).AddMonths(1).AddDays(-1) 1:I useDateTime now = DateTime.Today;var lastDate = new DateTime(now.Year, now.Month, DateTime.DaysInMon

Swift converting between UInt and Int

Swift converting between UInt and Int

I have the following methodsvar photos = [MWPhoto] = [MWPhoto]()func numberOfPhotosInPhotoBrowser(photoBrowser: MWPhotoBrowser!) -> UInt { return self.photos.count}func photoBrowser(photoBrowser: MWPhotoBrowser!, photoAtIndex index: UInt