I worked some more on this last night and made some good progress. Our models previously were manually extracting values from the TablularData for the CloudDB data row. This meant we hard coded which column index to read. It’s not flexible. I could write code to generate a proxy class derived from the model which would be marked a virtual. However, that would cause problems on medium trust, so I went with basic Reflection to find properties and a custom attribute to specify the CloudDb column name. Here’s what that looks like:
1: public class CloudDBColumnAttribute : Attribute
2: {
3: public string Name { get; set; }
4:
5: public CloudDBColumnAttribute(string name)
6: {
7: Name = name;
8: }
9: }
Use that to tag your properties:
1: [CloudDBColumn("id")]
2: public Guid Id { get; set; }
Just use GetType().GetProperties() to find the properties for the class, and then check if that property is tagged like this:
1: object[] columnAttributes = info.GetCustomAttributes(typeof(CloudDBColumnAttribute), true);
2: if (columnAttributes == null || columnAttributes.Length == 0 || !(columnAttributes[0] is CloudDBColumnAttribute)) continue;
You can then loop through each of the tagged properties and find the corresponding column in the TabularData to find the right column. Then take that index to get the right value from the Row fields. The end result is an easy way to set property values from CloudDB data.
1: public static T Open(TabularData data, Row row)
2: {
3: T item = new T();
4: item.Map(data, row);
5: return item;
6: }
I’ll post more later, and I’ll provide code on request.
blog comments powered by
This is just a quick public challenge. I’m big on challenging habits and decisions based on tradition. Using an RDBMS by default for your application is a common thing most of us do; myself included. While I’m not taking a position on the rise of NOSQL, I encourage everyone to challenger their thinking on using RDBMS. Why do you use it? Is it really the right solution for your data needs?
Please read these posts from Rob Conery, and then think about it.
Hello from 2020, then Reporting in NOSQL and NoSQL – A Practical Approach Part 1
Also, found this from High Scalability website.
I’ve brought this up with colleagues and got some interesting blow back from some of them. My point is that you should question all of you’re technology decisions; not just whether to user WPF or Silverlight, etc. I’ll probably play with something link MongoDB when I get a chance. There is a nice little screencast about the MongoMapper for rails on Railscasts.
blog comments powered by
I’ve finally got a rails 3 beta app running. (Woohoo!) It’s nothing special; just started with the usual “rails newappname” and then ran it. There are lots of changes in things I’ve depended on, but I’m not going to recount them here. My setup on my MacBook is: RVM for Ruby 1.9.1 Rails 3.0.0.beta & Rails 2.3.5.
RVM lets you easily install and switch between different Ruby versions. It works great; I remove my MacPorts install of Ruby and it was pretty easy to get going.
RVM: http://rvm.beginrescueend.com/
Rails3: http://guides.rails.info/3_0_release_notes.html
And now for something completely different.
I know I keep repeating this, but I really enjoy using Heroku (@heroku) and have TimesheetToaster (@timesheettoast) hosted there. If you know git, deplpoying your app is about as easy as file copy once you are setup. Setting up your app isn’t that hard, and learning git is also easy. You can learn git from here or here.
I could have written TimesheetToaster in .Net, but chose rails because I like to try new things and Heroku was a promising service for hosting it. I actually started writing it in .Net but decided I wanted to go the rails route partly because of Heroku. I recommend it.
blog comments powered by
I’ve been seeing a lot of complaints lately about discussion among Alt.netters getting mean or visceral. Maybe I’m just toning out the right things or am not privy to those discussions. I still see a lot of good, helpful people in the so-called alt.net community. Even at Microsoft; see the Gu shift post. From helping solve problems to really off topic help, there are just a lot of good devs out there.
We devs can easily get negative because of our predominant traits for analyzing and problem solving. It’s just not fun or appropriate after a certain point. I’d be less inclined to go to a meeting or conference where the majority of conversation is complaining or stupid opinion arguments. Fortunately, I just don’t see a lot of that. Finding a better way is my main objective in exploring ideas, and I think the same is for other alt.netters. If I’m naive about this, then fine because I have a positive view of many others out there on the intertubes.
As a warning, please remember this: nobody’s perfect, everybody has opinions, personal style should be respected, and getting the job done and getting along are very important. Thanks to all those who have taken the time to help or chat with me. I hope to be as helpful in return or to others.
Here’s a little cred to some of the many who deserve it:
There are more. I just wanted to make the point there are plenty of good devs out there.
blog comments powered by