Azure.Mobile.Server.EntityData ModelState is invalid… why?

So, I have been building an ASP.NET MVC 5 web application making use of the Azure.Mobile.Server SDK.  So I created my model objects, and everything is excellent.  I used the scaffolding to generate my Controllers and Views.  From there I spent some time customizing my views, which I hate to do.  I’m not a very good front-end developer, and I have all the respect in the world for those who are skilled at making things look pretty.  So I went to test the various CRUD operations and starting at Create, I failed.  I set a breakpoint and found out that my model state was invalid.  The default code does something like this:

When I was clicking the submit button on my form, the check of ModelState.IsValid was coming back false.  This is because in my form, I was only adding data to “ModelProperty.”  The rest of the bindings (Id, Version, CreatedAt, UpdatedAt, Deleted) are all part of the Microsoft.Azure.Mobile.Server.EntityData object type which I inherited in my model.  I use this data type because I have an accompanying mobile app and the Mobile SDK does a great job of offline syncing my data.  So… I had to remove those bindings from the [Bind(Include = “…”)] statement.  Once I removed those, my ModelState was valid, and life continued.

Greatest Common Denominator/Divisor/Factor (Geek Style – Euclidean Algorithm)

I recall learning about performing fractional math when I was young.  To be completely honest, I never actually learned an efficient way of determining greatest common denominator.  I brute forced it most of the time, meaning I just kept trying numbers until it seemed like I got the right denominator.  My method was very similar to what you see here at Kahn Academy.  As part of an algorithms course, I needed to write a function to determine the Greatest Common Denominator.  Any time you start talking about writing code

Any time you start talking about writing code, and you consider performing a function that “brute forces” an answer, your code will not run very fast.  Sometimes, you have no choice but to brute force a solution.  Sometimes there is a better way.  In this case, brute force is not the best way.  Here is how a brute force method would look:

Continue reading → Greatest Common Denominator/Divisor/Factor (Geek Style – Euclidean Algorithm)

Shuffle a list C# (Fisher-Yates shuffle)

So, recently I was writing some code, and I was presented with a problem.  I had a List<CustomObject> in C#.  I needed to jumble that list up and still use those items.  Keeping in mind that I am not one of these prodigies that went to MIT, and I do not memorize algorithms for fun, I set about like most good programmers to Stack Overflow.  I came across this post which provided me this code: Continue reading → Shuffle a list C# (Fisher-Yates shuffle)