{"QuestionId": 6704769, "AnswerCount": 3, "Tags": "", "CreationDate": "2011-07-15T09:01:25.847", "AcceptedAnswerId": null, "Title": "Entity Framework - trying to insert null values when creating a new object", "Body": "

I'm having the same problem that a few of you have had - when trying to insert a new object, EF inserts null values for some of their properties, and the insert fails.

\n\n

First let me describe the structure of our DB. Its an event management system, in which each event needs to be associated with a practice group, stored in a cache table but ultimately fetched from Active Directory. I manually created the join table - is that a problem? Anyway, so Event has a foreign key pointing to EventPracticeGroup, which has a foreign key pointing to PracticeGroupCache. PracticeGroupCache also has a RegionId pointing to the Regions table.

\n\n

The problem comes when trying to insert a new EventPracticeGroup object. Below is the code I'm currently using:

\n\n
var eventPracticeGroup = new EventPracticeGroup();\nif (TryUpdateModel<EventPracticeGroup>(eventPracticeGroup))\n{\n    /*\n    var eventId = EventScheduleRepository.GetById(Convert.ToInt32(Request.QueryString[\"EventScheduleId\"])).EventId;\n    eventPracticeGroup.Event = EventRepository.GetById(eventId);\n    eventPracticeGroup.PracticeGroupCache = PracticeGroupCacheRepository.GetById(eventPracticeGroup.PracticeGroupCacheId);\n    eventPracticeGroup.PracticeGroupCache.Region = RegionRepository.GetById(eventPracticeGroup.PracticeGroupCache.RegionId);\n    EventPracticeGroupRepository.Add(eventPracticeGroup);\n    */\n\n    var eventId = EventScheduleRepository.GetById(Convert.ToInt32(Request.QueryString[\"EventScheduleId\"])).EventId;\n    var theEvent = new Event() { Id = eventId };\n    EventRepository.Repository.UnitOfWork.Context.AttachTo(\"Events\",theEvent);\n    var practiceGroupCache = new PracticeGroupCache() { Id = eventPracticeGroup.PracticeGroupCacheId };\n    practiceGroupCache.Region = new Region() { Id = eventPracticeGroup.PracticeGroupCache.RegionId };\n    eventPracticeGroup.PracticeGroupCache = practiceGroupCache;\n    EventPracticeGroupRepository.Add(eventPracticeGroup);\n    EventPracticeGroupRepository.Save();\n    return RedirectToAction(\"Index\");\n}\n
\n\n

Anyway... as you can see, I've just tried using stub objects (no help), and I've also tried actually fetching and setting the objects. The error I get is:

\n\n
\n

Cannot insert the value NULL into column 'Name', table 'XXXX.dbo.Regions'; column does not allow nulls. INSERT fails. The statement has been terminated.

\n
\n\n

Obviously name is not a key field. I have checked the EDMX XML - only the Id (primary key columns) have StoreGeneratedPattern set to Identity, as they should (they are int32 identity columns). Not a single foreign key has StoreGeneratedPattern set to identity.

\n\n

if I set Regions.Name to allow nulls, PracticeGroupCaches.Description throws the same error. It seems that every linked object gets set to null. I did have a look with the debugger, when I used the now commented out code, nothing was null and everything had a value. I even got the RegionRepository to return all of the regions, just to see if one of them somewhere had a null name. None did. There are only 2 in my test DB. Our object context is shared per HTTP request.

\n\n

Please can anyone help. At this point I would settle for using the dirtiest workaround as long as it worked.

\n\n

Regards,\nJonathan.

\n", "Lable": "No"} {"QuestionId": 6754944, "AnswerCount": 5, "Tags": "", "CreationDate": "2011-07-19T22:36:44.437", "AcceptedAnswerId": "6754981", "Title": "where is my database saved when I create it in MySQL?", "Body": "

I'm completely new to ubuntu and MySQL and I created a new database via:

\n\n
mysql -u root -p\ncreate database mydb;\n
\n\n

Now, in which directory is this database saved and how do I specify where it's saved when I create it?

\n", "Lable": "No"} {"QuestionId": 6779291, "AnswerCount": 1, "Tags": "<.net>", "CreationDate": "2011-07-21T16:15:30.047", "AcceptedAnswerId": null, "Title": "Windows Phone ControlTemplate & Converter : problem loading BitmapImage from Image Resource in assembly", "Body": "

This is basically a follow up to my previous question.\nI've managed to make this work with the templates, however, I want to make it a bit generic, so that I don't have to go around repeating code all over the place

\n\n

The working version (hardcoded) is this :

\n\n
    <UserControl.Resources>\n        <ControlTemplate x:Key=\"TrebleCheckboxImageTemplate\" TargetType=\"CheckBox\">\n            <Image x:Name=\"imgTreble\" MinWidth=\"100\" Source=\"Images/treble_checked.png\">\n                <VisualStateManager.VisualStateGroups>\n                    <VisualStateGroup x:Name=\"CheckStates\">\n                        <VisualState x:Name=\"Checked\">\n                            <Storyboard>\n                                    <ObjectAnimationUsingKeyFrames BeginTime=\"00:00:00\" Storyboard.TargetName=\"imgTreble\" Storyboard.TargetProperty=\"(Image.Source)\">\n                                        <DiscreteObjectKeyFrame KeyTime=\"00:00:00\">\n                                                <DiscreteObjectKeyFrame.Value>\n                                                        <BitmapImage UriSource=\"Images/treble_checked.png\" />\n                                                </DiscreteObjectKeyFrame.Value>\n                                        </DiscreteObjectKeyFrame>\n                                    </ObjectAnimationUsingKeyFrames>\n                                </Storyboard>\n                        </VisualState>\n                        <VisualState x:Name=\"Unchecked\">\n                            <Storyboard>\n                                <ObjectAnimationUsingKeyFrames BeginTime=\"00:00:00\" Storyboard.TargetName=\"imgTreble\" Storyboard.TargetProperty=\"(Image.Source)\">\n                                    <DiscreteObjectKeyFrame KeyTime=\"00:00:00\">\n                                            <DiscreteObjectKeyFrame.Value>\n                                                    <BitmapImage UriSource=\"Images/treble_unchecked.png\" />\n                                            </DiscreteObjectKeyFrame.Value>\n                                    </DiscreteObjectKeyFrame>\n                                    </ObjectAnimationUsingKeyFrames>\n                            </Storyboard>                           \n                        </VisualState>\n                        <VisualState x:Name=\"Indeterminate\"/>\n                    </VisualStateGroup>\n                </VisualStateManager.VisualStateGroups>\n            </Image>\n\n        </ControlTemplate>\n    </UserControl.Resources>\n\n\n<StackPanel x:Name=\"LayoutRoot\" Background=\"{StaticResource PhoneForegroundBrush}\" Orientation=\"Horizontal\">\n        <CheckBox Height=\"72\" HorizontalAlignment=\"Left\" Background=\"White\" VerticalAlignment=\"Top\" Template=\"{StaticResource TrebleCheckboxImageTemplate}\" Margin=\"0,0,10,0\" >\n            <Custom:Interaction.Triggers>\n                <Custom:EventTrigger EventName=\"Click\">\n                    <GalaSoft_MvvmLight_Command:EventToCommand CommandParameter=\"{Binding RelativeSource={RelativeSource Self}, Path=IsChecked}\" Command=\"{Binding TreblePressedCommand}\"/>\n                </Custom:EventTrigger>\n            </Custom:Interaction.Triggers>\n        </CheckBox>\n\n    </StackPanel>\n
\n\n

Of course, the image paths are hardcoded. So, i wanted to make it generic, so that you could just instantiate a checkbox, tell it it's image, and the template would be the same for all.

\n\n

I created an ImageCheckbox control class :

\n\n
public class ImageCheckbox : CheckBox\n    {\n\n        /// <summary>\n        /// The <see cref=\"CheckedImagePath\" /> dependency property's name.\n        /// </summary>\n        public const string CheckedImagePathPropertyName = \"CheckedImagePath\";\n\n        /// <summary>\n        /// Gets or sets the value of the <see cref=\"CheckedImagePath\" />\n        /// property. This is a dependency property.\n        /// </summary>\n        public string CheckedImagePath\n        {\n            get\n            {\n                return (string)GetValue(CheckedImagePathProperty);\n            }\n            set\n            {\n                SetValue(CheckedImagePathProperty, value);\n            }\n        }\n\n        /// <summary>\n        /// Identifies the <see cref=\"CheckedImagePath\" /> dependency property.\n        /// </summary>\n        public static readonly DependencyProperty CheckedImagePathProperty = DependencyProperty.Register(\n            CheckedImagePathPropertyName,\n            typeof(string),\n            typeof(ImageCheckbox),\n            new PropertyMetadata(null));\n\n\n        /// <summary>\n        /// The <see cref=\"UnCheckedImagePath\" /> dependency property's name.\n        /// </summary>\n        public const string UnCheckedImagePathPropertyName = \"UnCheckedImagePath\";\n\n        /// <summary>\n        /// Gets or sets the value of the <see cref=\"UnCheckedImagePath\" />\n        /// property. This is a dependency property.\n        /// </summary>\n        public string UnCheckedImagePath\n        {\n            get\n            {\n                return (string)GetValue(UnCheckedImagePathProperty);\n            }\n            set\n            {\n                SetValue(UnCheckedImagePathProperty, value);\n            }\n        }\n\n        /// <summary>\n        /// Identifies the <see cref=\"UnCheckedImagePath\" /> dependency property.\n        /// </summary>\n        public static readonly DependencyProperty UnCheckedImagePathProperty = DependencyProperty.Register(\n            UnCheckedImagePathPropertyName,\n            typeof(string),\n            typeof(ImageCheckbox),\n            new PropertyMetadata(null));\n\n\n    }\n
\n\n

I created a converter (because I ran into the problem that I must convert the string to be the Uri for the image source)

\n\n
public class StringToImageConverter : IValueConverter\n    {\n        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)\n        {\n            if (value == null)\n            {\n                return null;\n            }\n\n            if (!UriParser.IsKnownScheme(\"pack\"))\n            {\n                UriParser.Register(new GenericUriParser\n                    (GenericUriParserOptions.GenericAuthority), \"pack\", -1);\n            }\n\n            if (value is string)\n            {\n                var image = new BitmapImage();\n                image.UriSource = new Uri(String.Format(@\"pack://application:,,/Images/{0}\", value as string));\n                //image.UriSource = new Uri(String.Format(@\"pack://application:,,,/Adagio.Presentation;component/Images/{0}\", value as string),UriKind.Absolute);\n                image.ImageFailed += new EventHandler<System.Windows.ExceptionRoutedEventArgs>(image_ImageFailed);\n                image.ImageOpened += new EventHandler<System.Windows.RoutedEventArgs>(image_ImageOpened);\n                return image;\n            }\n\n            if (value is Uri)\n            {\n                var bi = new BitmapImage {UriSource = (Uri) value};\n                return bi;\n            }\n            return null;\n        }\n\n        void image_ImageOpened(object sender, System.Windows.RoutedEventArgs e)\n        {\n            throw new NotImplementedException();\n        }\n\n        void image_ImageFailed(object sender, System.Windows.ExceptionRoutedEventArgs e)\n        {\n            throw new NotImplementedException();\n        }\n\n        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)\n        {\n            throw new NotImplementedException();\n        }\n    }\n
\n\n

you can see that the converter has been tried with thousands of different combinations, none of them work...\nThen, the new xaml :

\n\n
<ControlTemplate x:Key=\"CheckboxImageTemplate\" TargetType=\"Controls:ImageCheckbox\">\n            <Image x:Name=\"imgForTemplate\" MinWidth=\"100\" Source=\"{Binding RelativeSource={RelativeSource TemplatedParent},Path=CheckedImagePath, Converter={StaticResource stringToImageConverter}}\">\n                <!--\n                <VisualStateManager.VisualStateGroups>\n                    <VisualStateGroup x:Name=\"CheckStates\">\n                        <VisualState x:Name=\"Checked\">\n                            <Storyboard>\n                                <ObjectAnimationUsingKeyFrames BeginTime=\"00:00:00\" Storyboard.TargetName=\"imgForTemplate\"  Storyboard.TargetProperty=\"(Image.Source)\">\n                                    <DiscreteObjectKeyFrame KeyTime=\"00:00:00\">\n                                        <DiscreteObjectKeyFrame.Value>\n                                            <BitmapImage UriSource=\"{Binding RelativeSource={RelativeSource TemplatedParent},Path=CheckedImagePath, Converter={StaticResource stringToImageConverter}}\" />\n                                        </DiscreteObjectKeyFrame.Value>\n                                    </DiscreteObjectKeyFrame>\n                                </ObjectAnimationUsingKeyFrames>\n                            </Storyboard>\n                        </VisualState>\n                        <VisualState x:Name=\"Unchecked\">\n                            <Storyboard>\n                                <ObjectAnimationUsingKeyFrames BeginTime=\"00:00:00\" Storyboard.TargetName=\"imgForTemplate\" Storyboard.TargetProperty=\"(Image.Source)\">\n                                    <DiscreteObjectKeyFrame KeyTime=\"00:00:00\">\n                                        <DiscreteObjectKeyFrame.Value>\n                                            <BitmapImage UriSource=\"{Binding RelativeSource={RelativeSource TemplatedParent},Path=UnCheckedImagePath, Converter={StaticResource stringToImageConverter}}\" />\n                                        </DiscreteObjectKeyFrame.Value>\n                                    </DiscreteObjectKeyFrame>\n                                </ObjectAnimationUsingKeyFrames>\n                            </Storyboard>\n                        </VisualState>\n                        <VisualState x:Name=\"Indeterminate\"/>\n                    </VisualStateGroup>\n                </VisualStateManager.VisualStateGroups>-->\n            </Image>\n\n        </ControlTemplate>\n\n<StackPanel x:Name=\"LayoutRoot\" Background=\"{StaticResource PhoneForegroundBrush}\" Orientation=\"Horizontal\">\n        <Controls:ImageCheckbox CheckedImagePath=\"treble_checked.png\" UnCheckedImagePath=\"treble_unchecked.png\" Height=\"72\" HorizontalAlignment=\"Left\" VerticalAlignment=\"Top\" Template=\"{StaticResource CheckboxImageTemplate}\" Margin=\"0,0,10,0\" >\n            <Custom:Interaction.Triggers>\n                <Custom:EventTrigger EventName=\"Click\">\n                    <GalaSoft_MvvmLight_Command:EventToCommand CommandParameter=\"{Binding RelativeSource={RelativeSource Self}, Path=IsChecked}\" Command=\"{Binding TreblePressedCommand}\"/>\n                </Custom:EventTrigger>\n            </Custom:Interaction.Triggers>\n        </Controls:ImageCheckbox>\n\n    </StackPanel>\n
\n\n

I've tried to make it all work at first, but I don't seem to even get the first Source property of the image to load. The commented part (VisualStateManager states) doesn't work either, but i think it must be the same problem.. in this case I'd need a converter to return an Uri instead of a BitmapImage, because UriSource is of type Uri, and Source is of type Image.\nI'm getting errors in the converter, where I can't load the images (always falling into the image_imageFailed event). I've set the images as resources in the assembly... what am i doing wrong?? this is driving me crazy!!!!

\n\n

[EDIT] : I've tried doing as suggested, and changed the dependency property to Uri, but I can't get it to work\nIf i say

\n\n
<Controls:ImageCheckbox CheckedImagePath=\"Images/treble_checked.png\" UnCheckedImagePath=\"Images/treble_unchecked.png\" Height=\"72\" HorizontalAlignment=\"Left\" VerticalAlignment=\"Top\" Template=\"{StaticResource CheckboxImageTemplate}\" Margin=\"0,0,10,0\" >\n
\n\n

and in the template's VisualState :

\n\n
<BitmapImage UriSource=\"{Binding Path=UnCheckedImagePath, RelativeSource={RelativeSource TemplatedParent}}\" />\n
\n\n

it tells me that the xaml isn't valid and get an error. If i use TemplateBinding like this :

\n\n
<BitmapImage UriSource=\"{TemplateBinding UnCheckedImagePath}\" />\n
\n\n

it doesn't complain, but the image doesn't load (appear blank). I think i'm getting close, but still haven't found the solution...

\n\n

[EDIT 2] : last try...

\n\n

usage :

\n\n
<StackPanel x:Name=\"LayoutRoot\" Background=\"{StaticResource PhoneForegroundBrush}\" Orientation=\"Horizontal\">\n        <Controls:ImageCheckbox Style=\"{StaticResource TheImageCheckboxStyle}\" CheckedImagePath=\"Images/treble_checked.png\" UnCheckedImagePath=\"Images/treble_unchecked.png\" Height=\"72\" HorizontalAlignment=\"Left\" VerticalAlignment=\"Top\" Margin=\"0,0,10,0\" >\n            <Custom:Interaction.Triggers>\n                <Custom:EventTrigger EventName=\"Click\">\n                    <GalaSoft_MvvmLight_Command:EventToCommand CommandParameter=\"{Binding RelativeSource={RelativeSource Self}, Path=IsChecked}\" Command=\"{Binding TreblePressedCommand}\"/>\n                </Custom:EventTrigger>\n            </Custom:Interaction.Triggers>\n        </Controls:ImageCheckbox>\n\n    </StackPanel>\n
\n\n

style (trying to copy what you pasted and removing what i thought are unnecessary parts)

\n\n
<UserControl.Resources>\n\n        <Style x:Key=\"TheImageCheckboxStyle\" TargetType=\"Controls:ImageCheckbox\">\n            <Setter Property=\"Template\">\n                <Setter.Value>\n                    <ControlTemplate TargetType=\"CheckBox\">\n                        <Grid Background=\"Transparent\">\n                            <VisualStateManager.VisualStateGroups>                                   \n                                <VisualStateGroup x:Name=\"CheckStates\">\n                                    <VisualState x:Name=\"Checked\">\n                                        <Storyboard>\n                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName=\"CheckMark\"\n                                                                           Storyboard.TargetProperty=\"Visibility\">\n                                                <DiscreteObjectKeyFrame KeyTime=\"0\">\n                                                    <DiscreteObjectKeyFrame.Value>\n                                                        <Visibility>Visible</Visibility>\n                                                    </DiscreteObjectKeyFrame.Value>\n                                                </DiscreteObjectKeyFrame>\n                                            </ObjectAnimationUsingKeyFrames>\n                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName=\"CheckMark\"\n                                                                           Storyboard.TargetProperty=\"Source\">\n                                                <!--  Magic!  -->\n                                                <DiscreteObjectKeyFrame KeyTime=\"0\"\n                                                                        Value=\"{Binding RelativeSource={RelativeSource TemplatedParent}, Path=CheckedImagePath}\" />\n                                            </ObjectAnimationUsingKeyFrames>\n                                        </Storyboard>\n                                    </VisualState>\n                                    <VisualState x:Name=\"Unchecked\">\n                                        <Storyboard>\n                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName=\"CheckMark\"\n                                                                           Storyboard.TargetProperty=\"Visibility\">\n                                                <DiscreteObjectKeyFrame KeyTime=\"0\">\n                                                    <DiscreteObjectKeyFrame.Value>\n                                                        <Visibility>Visible</Visibility>\n                                                    </DiscreteObjectKeyFrame.Value>\n                                                </DiscreteObjectKeyFrame>\n                                            </ObjectAnimationUsingKeyFrames>\n                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName=\"CheckMark\"\n                                                                           Storyboard.TargetProperty=\"Source\">\n                                                <!--  Magic!  -->\n                                                <DiscreteObjectKeyFrame KeyTime=\"0\"\n                                                                        Value=\"{Binding RelativeSource={RelativeSource TemplatedParent}, Path=UnCheckedImagePath}\" />\n                                            </ObjectAnimationUsingKeyFrames>\n                                        </Storyboard>\n                                    </VisualState>\n                                </VisualStateGroup>\n                            </VisualStateManager.VisualStateGroups>\n                            <Grid Margin=\"{StaticResource PhoneTouchTargetLargeOverhang}\">\n                                <Grid.ColumnDefinitions>\n                                    <ColumnDefinition Width=\"32\" />\n                                    <ColumnDefinition Width=\"*\" />\n                                </Grid.ColumnDefinitions>\n                                <Border x:Name=\"CheckBackground\"\n                                        Width=\"32\"\n                                        Height=\"32\"\n                                        HorizontalAlignment=\"Left\"\n                                        VerticalAlignment=\"Center\"\n                                        Background=\"{TemplateBinding Background}\"\n                                        BorderBrush=\"{TemplateBinding Background}\"\n                                        BorderThickness=\"{StaticResource PhoneBorderThickness}\"\n                                        IsHitTestVisible=\"False\" />\n                                <Rectangle x:Name=\"IndeterminateMark\"\n                                           Grid.Row=\"0\"\n                                           Width=\"16\"\n                                           Height=\"16\"\n                                           HorizontalAlignment=\"Center\"\n                                           VerticalAlignment=\"Center\"\n                                           Fill=\"{StaticResource PhoneRadioCheckBoxCheckBrush}\"\n                                           IsHitTestVisible=\"False\"\n                                           Visibility=\"Collapsed\" />\n                                <!--  Magic! Default to UnCheckedImagePath  -->\n                                <Image x:Name=\"CheckMark\"\n                                       Width=\"24\"\n                                       Height=\"18\"\n                                       HorizontalAlignment=\"Center\"\n                                       VerticalAlignment=\"Center\"\n                                       IsHitTestVisible=\"False\"\n                                       Source=\"{Binding RelativeSource={RelativeSource TemplatedParent}, Path=UnCheckedImagePath}\"\n                                       Stretch=\"Fill\"\n                                       Visibility=\"Collapsed\" />\n                                <ContentControl x:Name=\"ContentContainer\"\n                                                Grid.Column=\"1\"\n                                                Margin=\"12,0,0,0\"\n                                                Content=\"{TemplateBinding Content}\"\n                                                ContentTemplate=\"{TemplateBinding ContentTemplate}\"\n                                                Foreground=\"{TemplateBinding Foreground}\"\n                                                HorizontalContentAlignment=\"{TemplateBinding HorizontalContentAlignment}\"\n                                                Padding=\"{TemplateBinding Padding}\"\n                                                VerticalContentAlignment=\"{TemplateBinding VerticalContentAlignment}\" />\n                            </Grid>\n                        </Grid>\n                    </ControlTemplate>\n                </Setter.Value>\n            </Setter>\n\n        </Style>\n
\n", "Lable": "No"} {"QuestionId": 6813415, "AnswerCount": 4, "Tags": "", "CreationDate": "2011-07-25T08:29:01.313", "AcceptedAnswerId": "6818334", "Title": "Ignoring .svn directories with Wix Heat?", "Body": "

I'm using the Heat tool to generate Wix markup to include a large number of files and folders in my setup. This was working fine, but I just realized that since I added the source folder to my Subversion repository, Heat wants to include the .svn folders too.

\n\n

Is there a way to tell Heat not to harvest files or folders that match a given criteria?

\n\n

I am currently using Wix 3.5.

\n", "Lable": "No"} {"QuestionId": 6859371, "AnswerCount": 3, "Tags": "", "CreationDate": "2011-07-28T13:01:01.990", "AcceptedAnswerId": "7084278", "Title": "AJAX post to ASP.Net web site is missing parameters", "Body": "

I have created an IHttpAsyncHandler that I'm trying to call using AJAX, with jQuery. The call succeeds, but I can't find my parameters on the server.

\n\n

Here is the AJAX call:

\n\n
function deleteViewModel(typename) {\n    var data = {\n        \"viewModel\": typename,\n        \"operation\": \"delete\"\n    };\n\n    $.ajax({\n        type: \"POST\",\n        url: \"<%= GetAppRoot() %>/viewModelGeneration.ashx\",\n        contentType: \"application/json\",\n        cache: false,\n        data: JSON.stringify(data),\n        beforeSend: function (xhr, settings) {\n            $(\"[id$=processing]\").dialog();\n        },\n        success: function (data) {\n            alert('Hey, I succeeded.');\n        },\n        error: function (xhr, status, err) {\n            alert('Play a sad trombone and frown.');\n\n        },\n        dataType: \"json\"\n    });\n}\n
\n\n

The call comes through on the server and is handled by my handler, but I do not see either the viewModel or operation parameters there:

\n\n
public void ProcessRequest(HttpContext context)\n{\n    // Problem is here - no parameters!\n    var viewModelName = context.Request.Params[\"viewModel\"];\n    var operation = context.Request.Params[\"operation\"];\n\n    // Other stuff...\n\n    GenerateResponse(context.Response, jsonResp);\n}\n
\n\n

I popped open Fiddler to get a look at the request being sent from the client, and it appears to me that the parameters are included:

\n\n
POST http://localhost:4638/admin/viewModelGeneration.ashx HTTP/1.1\nHost: localhost:4638\nUser-Agent: Mozilla/5.0 (Windows NT 5.1; rv:5.0) Gecko/20100101 Firefox/5.0\nAccept: application/json, text/javascript, */*\nAccept-Language: en-us,en;q=0.5\nAccept-Encoding: gzip, deflate\nAccept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7\nConnection: keep-alive\nContent-Type: application/json; charset=UTF-8\nX-Requested-With: XMLHttpRequest\nReferer: http://localhost:4638/admin/Admin/ResetViewModels.aspx\nContent-Length: 123\nCookie: ASP.NET_SessionId=ifmof1ole4yv20jr0frqc0lk; .ASPXFORMSAUTH=836B7EEC539B1304126C156CA20A925DD4FF832E628C807A1CA9DCD00833BDFF36D73C39B9CCFE6EA15CF9FED95157A1CA5F07D588F04A8AFE68ABDBBA82FE9FF8507CB2B471340917616818334BCF0D958CB231A1CA3B9D91B05F2897C44663B5E86FC2FFDFE3C325AB66EC3124144F87B6FC8D3F6C7F92F2FEE745EA71EB333D18E35A7FFA992F8F52FEE509043236\nPragma: no-cache\nCache-Control: no-cache\n\n{\"viewModel\":\"Rds.ViewModels.Updaters.RegionViewModelUpdater, Rds.ViewModels\",\"operation\":\"delete\"}\n
\n\n

I'm not sure what's happening that they are not coming across on the server. Any thoughts would be appreciated.

\n\n

UPDATE:

\n\n

Someone suggested to me that Request.Params only supports forms-encoded data. I updated my AJAX call to this, but still no parameters server-side:

\n\n
function updateViewModel(typename, operation) {\n    var parms = {\n        \"viewModel\": typename,\n        \"operation\": operation\n    };\n\n    $.ajax({\n        type: \"POST\",\n        url: \"/admin/viewModelGeneration.ashx\",\n        contentType: \"application/json\",\n        cache: false,\n        data: parms,\n        beforeSend: function (xhr, settings) {\n                $(\"[id$=processing]\").dialog();\n        },\n        success: onSuccess,\n        error: onError\n    });\n}\n
\n", "Lable": "No"} {"QuestionId": 6917848, "AnswerCount": 1, "Tags": "", "CreationDate": "2011-08-02T19:58:59.007", "AcceptedAnswerId": "6917888", "Title": "How do I make a custom unretained class?", "Body": "

How can I make it so that I can get an unretained instance of a class? You can do this with various Cocoa classes like NSString ([NSString string]) or NSArray ([NSArray array]).

\n\n

How can I do this with my custom class so I can call [MyClass class] instead of [[MyClass alloc]init]?

\n", "Lable": "No"} {"QuestionId": 6950929, "AnswerCount": 1, "Tags": "", "CreationDate": "2011-08-05T03:01:15.857", "AcceptedAnswerId": null, "Title": "web service returning reliable proxy addresses", "Body": "

I'm looking for a proxy service (free or subscription) that I can programmatically request a random ip from that I can use to automate some manual testing.

\n\n

I'd like the service to have at least hundreds of ips it can select from to avoid repetition.

\n\n

Anonymity is not required but reasonable reliability is.

\n\n

Any recommendations? Searches just seem to lead me to unreliable, popup crazy, free anonymous proxies lists.

\n", "Lable": "No"} {"QuestionId": 6952777, "AnswerCount": 1, "Tags": "", "CreationDate": "2011-08-05T07:17:57.130", "AcceptedAnswerId": "6953349", "Title": "jQuery mouse position on mousedown() without mousemove()", "Body": "

Can I get cursor position at mousedown(event) event, without using mousemove(event) continuously (thus waisting resources)? event.pageX returns NaN on mousedown

\n", "Lable": "No"} {"QuestionId": 6953094, "AnswerCount": 0, "Tags": "", "CreationDate": "2011-08-05T07:50:15.040", "AcceptedAnswerId": null, "Title": "NSArray Sorting not sorting correctly", "Body": "

I have a class (Piece) which has a NSMutableArray property called attachedBlocks.

\n\n

Whenever piece is initialized, 4 Block objects are initialized and placed in attachedBlocks.

\n\n

At the same time, in my controller class, before I release piece, i add all blocks from piece.attachedBlocks to a NSMutableArray in my controller called boardBlocks. So boardBlocks has every block on the board in its array (hence the name).

\n\n

In a method in my constructor, I try sorting this boardBlock array so all objects on the board are sorted from bottom right to top left locations, so a block at (0,0) would come after (0,1), and (1,0) would come after (2,5).

\n\n

Here is the code for my sorting:

\n\n
//In Block.m:\n\n- (NSComparisonResult)compareTo:(Block *)other\n{\n    if (self.location.y < other.location.y && self.location.x < other.location.x)\n    {\n        return NSOrderedAscending;\n    }\n    else if (self.location.y == other.location.y && self.location.x == other.location.x)\n    {\n        return NSOrderedSame;\n    }\n    else\n    {\n        return NSOrderedDescending;\n    }\n}\n\n//In my controller.m\n\n- (void)sortTheArray\n{\n    NSArray *sortedBlocks = [boardBlocks sortedArrayUsingSelector:@selector(compareTo:)];\n\n    for (Block *b in boardBlocks)\n    {\n        NSLog(@\"%d, %d\", b.location.x, b.location.y);\n    }\n\n    for (Block *b in sortedBlocks)\n    {\n        NSLog(@\"(%d, %d)\", b.location.x, b.location.y);\n    }\n}\n
\n\n

Like I said before, each time a piece object is made, 4 block objects are initialized one after the other.

\n\n

When I do this after one piece was created and released, sorting works. However, when I try to utilize more than one piece, I get the following result:

\n\n

boardBlocks:

\n\n

(8, 17)\n(7, 18)\n(8, 18)\n(9, 18)\n(6, 17)\n(7, 17)\n(5, 18)\n(6, 18)

\n\n

The first piece consists of blocks at the first four coordinates.\nThe second piece consists of blocks at the second four coordinates

\n\n

The result after sorting:

\n\n

(6, 18)\n(5, 18)\n(7, 17)\n(6, 17)\n(9, 18)\n(8, 18)\n(7, 18)\n(8, 17)

\n\n

The result should be:

\n\n

(9, 18)\n(8, 18)\n(7, 18)\n(6, 18)\n(5, 18)\n(8, 17)\n(7, 17)\n(6, 17)

\n\n

Now, you can see that it correctly sorts each piece one at a time (the top 4 coordinates are sorted correctly, and the last 4 are sorted correctly).. but together, they are not sorted correctly because (9, 18) should come before every other coordinate on there.

\n\n

Does the sorting occur when objects are initialized into an array automagically, or when sortedArrayUsingSelector: is called?

\n\n

I can't wrap my head around why it sorts the first four, then the second four, but not the entire array alltogether.

\n", "Lable": "No"} {"QuestionId": 6955445, "AnswerCount": 4, "Tags": "", "CreationDate": "2011-08-05T11:21:46.610", "AcceptedAnswerId": "6955531", "Title": "SQLite updation upon android app's update", "Body": "

I have an app released on the android market which uses sqlite and displays data. I want to know if I am sending an update for the app by adding features, should I upload a new database? What happens when users already having my app, click on update? Will the database update on its own? If the users are downloading my app for the first time, they will certainly get the new db content...but what about the existing users?? I want to know if I have to explicitly update the database in the program

\n", "Lable": "No"} {"QuestionId": 6978312, "AnswerCount": 3, "Tags": "", "CreationDate": "2011-08-08T06:07:45.560", "AcceptedAnswerId": "6993110", "Title": "iOS Core Animation - Fold a Layer", "Body": "

Using Core Animation, I would like to fold a UIView (i.e. it's CALayer) on it's center. i.e. I would set the anchor point as (0.5,0.5) & fold the layer. This image that I created in Photoshop might give the effect I am looking for -

\n\n

\"enter

\n\n

So, what's happening is, the layer is being folded on its center, as the fold is happening a little bit of perspective is applied (the infamous m34!). Initially, the view is parallel in X-Y plane with Z axis looking straight to the user. As the fold is happening, bottom half & top half at the same time move back (with some perspective, to give depth & 3D effect) till the entire layer is (parallel) in X-Z plane. Note that once the layer is parallel in X-Z plane, the user will no longer be able to see the Layer. But that's ok, that's the effect I am looking for. A UIView disappearing by folding on it's center.

\n\n

How would one go about doing this in iOS? Without using 2 different layers (for bottom & for top)? Any help is much appreciated...

\n\n

Update: As @miamk points out, this is the same UI effect used in \"Our Choice\" App or \"Flipboard\" App.

\n\n

UPDATE: I have offered bounty on this to get more specific answers. Would love to see -

\n\n
    \n
  1. Code samples.
  2. \n
  3. Advise from people who have done something like this.
  4. \n
  5. Even the way to achieve this in a detailed fashion (algo) is much appreciated.
  6. \n
\n", "Lable": "No"} {"QuestionId": 7125782, "AnswerCount": 1, "Tags": "", "CreationDate": "2011-08-19T18:26:13.920", "AcceptedAnswerId": "7126175", "Title": "Ruby on Rails, Split Model into Two Controllers/Forms, but update action calling parent", "Body": "

I have a model that for edit/update actions only is logically split into two forms. The model is Venue. I created app/controllers/venues_controller.rb. The two sub-forms are Details and Policies, so I created app/controllers/venues/details_controller.rb and app/controllers/venues/policies_controller.rb, as well as their corresponding views. The child controllers do inherit from VenuesController. I added the venues namespace to my routes, so it now looks like:\n resources :venues\n namespace :venues do\n :details, :policies\n end

\n\n

The routes work correctly, the correct views load, the \"edit\" action on the sub-controllers is called correctly. However, in the sub-views, I'm using the RESTful form_for(@venue), so when the form is POSTed (PUT) it is going to venue_path, not venue_details_path.

\n\n

I looked at the docs for form_for and can't figure out a way to keep my sub-forms restful. You can add a token for a namespace a la form_for([:namespace, @model]), but in my case, the model name is the namespace, so it's inverted.

\n\n

I really don't want to split the model itself, since that has other implications that would be harder to address.

\n\n

So far, I see two solutions, both of which I don't like:\n1. Let both views POST to VenuesController#update and deal with any differences there (more lame controller code)\n2. Use form_tag and _tag helpers (more lame view code)

\n\n

Am I missing something obvious? Is there something different I can do in the routes, or is there another way to call form_for?

\n\n

I've scanned some posts about Presenter and Conductor patterns but they don't seem to fit this problem. I've read a few stackoverflow threads about whether creating two controllers for one model koscher (it is), but nothing about this specific issue.

\n", "Lable": "No"}