Long Cloud Technologies
"... A Yankee in the Land of the Long White Cloud, Aotearoa ..."

Shouldn’t we have LINQ / Lambda functionality in SQL query analyzer?

So today I had a question from one of my compadres who isn’t very strong in T-SQL.  He had originally designed his database using a publically visible property to associate two tables which is a no-no in my book (and that’s a whole other article for another day, suffice it to say it is axiom 1 of my rule of databases, if the public can see a column, it can’t be used in a relationship).  He has worked with me long enough now to know that rule, and (with reservations based on not having complete faith that I am right for all circumstances) he, at my urging, decided since he was reworking his web app, he would take the hit and modify his database as well.

The issue he faces is that he wants to preserve his current data (can’t start over from scratch).  So he added the correct reference field to his database, and I told him its easy with a SQL statement to tell a table update to “find my matching record in the other table based on our shared key, and update my new relationship key with the ID of the matching row from the other table”, that’s a pretty easy t-sql statement, and he agreed as I said it, it seemed easy so he would do it.  Well I get an email from him asking

So if I write the same thing I want to do in pseudocode, can you translate it to SQL for me?? I could always just write a quick c# procedure that would do it otherwise...

for each (item in [dbo.OrderItem])
{
	var sizePriceUid
	sizePriceUid = SizePrice.Uid
	WHERE OrderItem.ProductPLU == SizePrice.ProductPLU
	INSERT (SizePriceUid) VALUES (sizePriceUid)
	INTO dbo.OrderItem.SizePriceUid
}

 

So I quickly prep the psuedo t-sql for him (leaving it to him to tweak it correctly)

Update orderitem
Set orderitem.sizepriceuid = SizePrice.Uid
From orderitem
Inner join sizeprice on 
	sizeprice.ProductPLU = Orderitem.productPLU

 

 

And that should be the end of that, but since I have promised myself that for the next 3 months I would take the time to write at least one blog entry for each day that I sit down at my computer to work (days off, I don’t have to) I realized here was a perfect opportunity to blog about something.  It occurred to me that I’ve been doing SQL and VB / C# programming for so long, I’m versatile in both, and I think it is a good to be learned in both. On the other hand, I don’t know COBOL, and at one time every thing important was written in it.  When I first got started in the business the “real” programmers all knew COBOL, I didn’t bother to learn it, and I’m doing pretty good so far.  Just because I know SQL and am comfortable in using it, that doesn’t mean it should stay that way for new programmers if there is a better way to do it.  My mate is really good at what he is doing for the little time he has been programming, and he constantly strives to better himself.  At my recommendation he has embraced LINQ and ASP.NET MVC.  He has gotten in on the ground floor of LINQ and I suspect that in years to come as it grows and is made more powerful he will become a Guru in it, just as I am today a good T-SQL guy.  So why should he have to become a good T-SQL guy. 

Well lets face it, he doesn’t have much of a choice. If he wants to play in the MS database development sphere, he needs to learn T-SQL, but that’s the whole point of LINQ (especially when combined with Lambda expressions), in his code he can program in the way he is most comfortable / experienced and unless he needs to do some real heavy duty optimization, he doesn’t have to “worry” about how exactly that logical Lambda / LINQ is translated and works in T-SQL, it just does.

Which brings me to my point (after taking the long way around to get here) shouldn’t SQL Management Studio, specifically the Query Windows, be made to support Lamda / LINQ?  Then my mate could do this in a way that makes sense to him.  Say something like this

dbo.OrderItem.Update(
	o => o.SizePriceUid = dbo.SizePrice.Single.Where(
	s => s.productPLU == o.productPLU).Uid
)

he should be able to put that in Query Analyzer, select his database to run it against , and LINQ with Lambda, should be able to do the rest (provided of course that MS makes LINQ and Lambda support the construct I’ve put there).  It just a thought, and if you think about it, really the way we should all move.  I don’t do much C++ work, unless I need to have bit wise control of optimization, I do .Net framework and take the hit in time I know I am taking because computing power has made that almost trivial for most things.  Seems to me, this would be a good way to go, T-SQL should only be for us old database cobol types who need to be called in on that rare occasion.

Besides then my skill becomes really specialized and my rates for that work can go up!  So I’m all for it!

Posted on 04 Mar 09 14:49 by matthew.hintzen |

Bookmark this post with:

E-mail | Comments(0) | Comment RSS


MVC and the ASP.NET IMembershipProvider, Oy Vay

I’m working with a colleague on a new ASP.NET MVC web application, and for various reasons he needed to implement some login security for the public.  So he decided to use the built in security provider that was built on top of the ASP.NET provided IMembershipProvider.

Now I have written my own implementation of a IMembershipProvider, and so I totally understand how it works (along with the role provider and the personalization provider); so my colleague asks me to explain how it all works (he is a fairly new programmer in the asp.net sphere)…

and that’s where I say “Oy Vay, do you have about a week to read, study, run tutorials and make hello world test beds?  because that is the only way you will really come to understand how it all works together.”

Because let’s face it folks its a MESS.  of all the things that is in DESPERATE need of being rebuilt from the ground up, using best lessons of all the things we now need security to do / support, the I<Security> framework needs it the most.

What’s worse, because it is so fundamental to what is used out there, we might as well forget ever seeing it updated.  The database structure itself is bad and needs to be better normalized.

I’m not going to hold my breath for the day it get’s changed.

Posted on 03 Mar 09 14:49 by matthew.hintzen |

Bookmark this post with:

E-mail | Comments(0) | Comment RSS


Windows Live Writer – Liking it… ALOT

So I have made a commitment over the next 3 months that as long as I sit down at my computer at least once a day, I will post at least one Blog entry (just to get in the habit).  So after getting my website all up and running I had to start looking for the the Blogging tools that made it easy and powerful.

After much searching and trying a few different ones, I have settled on the Windows Live Writer.  So far configuration, usage, and ease of use are all top of the line, and the price was right… free.

Sometimes Microsoft does put out great v1.0 apps.

I know that in actuality this program has been around for a while in many iterations, and has been relabeled as Live Writer, but it is a new name, and I’ve never used it before, so it gets my vote!

Posted on 02 Mar 09 14:48 by matthew.hintzen |

Bookmark this post with:

E-mail | Comments(0) | Comment RSS


VMWare Downgrading Image / VMWare Tools causes SysVol / GroupPolicy / RSOP failure – NOW WITH A FIX.

well I hit a big one today in trying to assist my client to set up a virtual network for testing our software application.

In order to work with (and test the software myself) I had bought and installed VMWare workstation ver 6.5 on my dev machines.  Since I had already gone to the trouble of setting up a virtual network that I had deployed on my machines, I thought we would just ship the images off to the client and they could install them… And thus the problems began.

First up, the client didn’t have VMWare 6.5, but instead 5.5.5, so after I had discovered that I had to export the images as downgraded images.  No problem there, and indeed we got them up and running on the client’s machine.  The first problem cropped up, once we got everything running.  The Virtual Domain was happy… but the mouse was choppy and just plain weird when ever it was over the vmware image.  A little digging around revealed that the mouse behavior was overseen on the image by the VMTools, and that’s where I started to go down the rabbit hole!

clip_image002

As you can see, I had put the VMware tools on the domain controller when it was created on my machines in VMware 6.5 (giving me tools of 6.5) but the client’s workstation was 5.5.5, so VMware tools were not “playing” nice with their containing VMware workstation. 

OK easy peasy, right… not so fast.  I’ll skip some of the drama I went thru but basically the problem turned out to be this…  When the VMware tools were ver 6.5, or when they were removed from the image all together the GroupPolicy system (and the RSOP snap-in) operated the way it was supposed to.

clip_image003

But just uninstall the 6.5 tools, then reinstall the 5.5 tools (that go with the workstation) and Viola, you have a broken domain controller.

I’ve spent the last day and a half trying all the “fixes” I can find for a sysvol permissions issue (which this clearly is) and in the end, I’ve decided to tell my client, either rebuild the network from scratch, or spend the $400 dollars and upgrade to 6.5 VMware workstation…

I think the smart thing will be to upgrade…


Well I thought about it a bit and it cogitating on what I had read when I was trying to fix it using technotes, it occurred to me that quite a few of the notes talked peripherally about “… process not able to contact domain controller…”  so I decide to look at what options are installed on the client when the VMware tools are pushed in (I used the Custom Install), and first up, I don’t have scsi so no need to install that, and then I saw that they had an option to “improve” the network card. 

Network, communication, failure… so playing a hunch that modifying the network process was a bad idea on the domain controller, I decide to skip that part of the VMware tools.

clip_image004

Unfortunately, that had no effect. upon completion of the VMware tool installation here is what I get when I try to look at the group policies for the domain

clip_image005

Click ok here gives

clip_image006

And finally the final SNAFU:

clip_image007

If I can come up with a work around, I’ll amend this entry to let you know what I found.


THE FIX.

If you look at the first image in this blog you will notice that the client is using Ver 5.5.1 of VMware workstation.  After I was done posting this entry, I basically threw up my hands and said, “never going to happen”.  But then while trolling thru the VMware website, I saw that there was an upgrade to the version of 5.x ver of workstation basically 5.5.9 and the update was free for my client’s license.  So figuring if I was going to ask the client to upgrade to 6.x which would cost money, let’s try the 5.5.9 free upgrade (that I was sure wouldn’t work).

And what do you know? It Worked.

After installing the 5.5.9 upgrade I started up the domain server, installed VMware tools, and whoo hoo, it was a happy camper.  So now I can get back to my REAL work.

Moral of the story.  Upgrade as far as you can for free before paying for a more advanced upgrade.

Posted on 01 Mar 09 14:47 by matthew.hintzen |

Bookmark this post with:

E-mail | Comments(0) | Comment RSS


Windows Azure Moving to UTC time – Well About Time! (pun intended)

Was doing my daily RSS feed trolling when I saw a new announcement from the Windows Azure team that they were converting Azure over to use UTC some time soon.

Azure Moving to UTC

Talk about red-faced, silly me, I’ve been developing against Azure down here in Kiwi land just assuming that it was already UTC.  Since they were trying to make global cloud computing, of course they would start with UTC… right?  Well apparently NO.  I may be a Yankee by birth (don’t blame me, please), but it is easy to forget how blissfully, when we are in the bubble of importance that is USA residence, we assume and code as if the whole world was the USA.

It not because we don't care, we really do, we just don't think about it. Here I've been developing international software for over 10 years, and its only since I moved to New Zealand that I now use UTC (and plan on it from the beginning) without having to remind myself to do so. So I'll cut the programmers back in Redmond a little slack... but not too much.

Make the switch guys (and as a international developer, thanks for making the switch).

Posted on 01 Mar 09 14:46 by matthew.hintzen |

Bookmark this post with:

E-mail | Comments(0) | Comment RSS