Blog ala Vidar

SQL, AppFrame and other cool technologies

Tag Archives: VB.NET

News from Ølen about stuff that matters

You might have noticed there was just a holiday. Something about Jesus eating some bad chicken, so everyone thought he died, but then he woke up a couple of days later feeling much better. Anyways, because of this bad chicken, I’ve been VERY busy the last week, playing Modern Warfare 2 on Xbox. Ai can has vacation 2!

AppFrame as a product!
Since I started in Omega I’ve been fighting for releasing AppFrame as a framework for developers outside Omega. Now that’s almost a reality. We’re soon going to offer AppFrame as a product, along side PIMS and our other products. There haven’t been any final decision on pricing and stuff, but I can guarantee it will be affordable. This means that all developers out there that want to use AppFrame as their Framework to make applications can soon start doing this! They MIGHT even get the source code! After releasing CR3 I’m now confident that this is an AWESOME product. If you’ve met me, you know I’m not a sales person. I always say what I mean, and I can say with my full heart that AppFrame is without a doubt a VERY good product to develop applications for customers! Contact me if you want a presentation (from a developer, or a sales person. Your choice!). I’ll probably post a blog about the details when there’s been a decision on price etc.

NNUG and MTUG Haugesund
I’m the chapter of NNUG (Norwegian .NET User Group) Haugesund. We had a meeting at Rica Maritim Hotel in Haugesund March 22nd. The speaker was Einar Ingebrigtsen, and he talked about creating games with managed code. That means, using Silverlight, XNA, DirectX and similar. We had a new record of attendees: 27! That’s really high, at least if you compare us to Bergen which is a MUCH bigger city, but they’ve got about an average of about 20 people every meeting.

Since I’m both interested in programming and hosting-related stuff, I thought it would be cool to start a user group that could concentrate about the IT Pro’s out there, just like NNUG is concentrating on MSDN-people. Timing perfect, as always, I read on twitter that a guy called Jan Egil Ring was about to start MTUG (Microsoft Technology User Group). I’ve offered myself as the contact person in Haugesund, and I’m now working on gathering people so we can get a committee to manage this group. I’ll keep all of you updated when we’ll start having meetings etc.

Except playing Xbox, what have I been doing lately? I’ve played a lot with Visual Studio 2010 RC. A hot tip for those of you thinking you’ll play with Silverlight 4 in the RC. Don’t even think about it. It doesn’t work. I didn’t know this, so after 6-7 hours of swearing, kicking, screaming etc. Erik (coworker and friend) told me that’s not possible. Well, thanks! After that I started playing with WPF, since it’s basically the same except that Silverlight is a wossy-version of WPF /me hides under the table, waiting for the Silverlight-folks to start screaming. I’ve already managed to create a simple twitter client, trying out LINQ to XML, LINQ to Entities and a couple of new minor changes to VB. The fact that you now can create a Property on a class with ONE line of code is awesome. And, yes, before you C#-fanatics say “we’ve had this for ages”, you now got optional parameters, which VB have had for about 1000 years. We now also got something that’s got a fancy name. “Implicit Line Continuation”, which basically means that you don’t have to end all lines with _ if you want to continue this line on the next. This was very annoying in for example LINQ, where you’ve got something like:

Dim v = From a In AppDomain.CurrentDomain.GetAssemblies _
		Where a.ToString.Length > 0
		Select a.ToString()

Here is a great example. On the first line you need to specify the _ at the end, if not you’re not “allowed” to continue, but you don’t need it on the Where-line. Pretty confusing. Well, now you don’t need it at all.

One other thing that I find really nice is the improved IntelliSense. Now you can start typing “To”, and you’ll get:

CompareTo, CopyTo, ToString etc

Before, you only got ToString, since that’s the only thing starting with To. You can also search for AD, and get AppDomain, since .NET uses Pascal Casing.


We’ve been working a bit on the blogs site. Or, to be honest, I’ve been making tasks and Stian has been doing them. The new (some of them are old, but you might not have noticed them before) features are: Tags. This works the same ways as Categories, except that you can tag an article with more than one Tag. We’ve then got Tag Clouds, to show which Tags are the most mentioned, and which are rarer.

If you’re using TeamDocuments, you will be auto-logged in which gives you the possibility of rating all posts, and commenting on them! You can even comment as an anonym user.

Johnny said today that he’ll start blogging more. Peter also had this statement a couple of weeks ago. Guess it’s just like X-files, “Du tror det ikke før du får se det!” (something like You won’t believe it before you see it!). But I would be very happy to see some posts from them too!

Build 5

The technology department released Build 5 of AppFrame a couple of weeks ago. Peter was our “speaker” at our last cake-meeting where he went through most of the changes done in this build. I’m really excited to start upgrading our clients to this release!

Issue Tracker

To report bugs (yes, we as everyone else, including Microsoft!, produce bugs), the technology department released a new “issue tracker”. This makes it SOOO much easier for me, since I now don’t have to read 10-15 TeamDocs every day to check if the bugs I’ve reported have been fixed. Most of the things I’m reporting is even getting fixed within a couple of hours (sometimes days), depending on the severity of the bug/suggestion. I’m strongly recommending you all to report everything you find, so we’ll get an even better product! Just today I’ve reported two things; resizing issues with the calendar in chrome and the distribution lists not working. They haven’t been fixed yet, but the distribution lists-thing is “in process”.


If you’ve got any suggestions on what you want me to blog about, or you’ve got comments, please send them to me! And remember to rate the posts! Good or bad. I won’t bite… Changed my mind. I will bite 🙂



LINQ stands for Language INtegrated Query and is a part of .NET Framework 3.5. You can use LINQ to any object you want as long as it implements the IQueryable interface, including XML and SQL which makes it very interesting. When I first heard about LINQ I thought that it sounded cool, but I was worries about performance. I still am worried, but it’s even cooler than I imagined! To test it out I started creating TeamDoc in WPF, using LINQ. I connected to one of our SQL servers, drag and dropped a couple of tables and sim salabim my LINQ to SQL was ready to be used. I then started creating a user control for “recent updates”. The SQL query behind this looks something like this:

		FROM stbl_TeamDoc_Websites WITH (NOLOCK)
		WHERE TeamDocRef = Table1.PrimKey) AS Url
		  C.PrimKey, C.Title, C.Status, C.Updated,
		  CASE WHEN C.Updated > ISNULL(US.LastRead,'1999-01-01')
			AND C.HideUntil  ISNULL(US.LastRead,'1999-01-01')
			     AND C.HideUntil <= GETUTCDATE()
			   THEN 1 ELSE 0 END DESC, C.Updated DESC) AS Table1

This, in LINQ looks something like this:

Dim vUpdatedDocuments = _
	(From d In vTeamDoc.Documents _
	Join us In vTeamDoc.UserSettings _
	On d.PrimKey Equals us.TeamDocRef _
	Where us.Login = Globals.Username _
	  AndAlso us.Notify = "Inbox" _
	  AndAlso d.Status = DocumentTypes.ToString() _
	  AndAlso d.Deleted Is Nothing _
	  AndAlso (From p In vTeamDoc.Permissions _
		   Join gm In vTeamDoc.GroupsMembers _
		   On p.GroupRef Equals gm.GroupRef
		   Where gm.Login = Globals.Username
		   Select p.TeamDocRef).Contains(d.PrimKey)
	Order By If(d.Updated > _
			If(us.LastRead.HasValue, us.LastRead, d.Updated.AddDays(-1)), 1, 0) Descending, _
	  d.Updated Descending _
	Take 30 _
	Distinct _
	Select New UpdatedDocument With _
	  {.Title = d.Title, .Updated = d.Updated, _
	   .LastRead = us.LastRead, .PrimKey = d.PrimKey})

I’m terrible sorry about the indenting and newlines, but I had to cut it to fit in here. Anyways, if you take a look at the LINQ query you’ll probably understand most of it. The only big difference is that I’m doing a Select New UpdatedDocument (on line 20). What this is doing is creating one UpdatedDocument (a class I’ve created) for each row returned by this query, and sets the properties .Title, .Updated etc. So, how do I loop this? VERY easy!

For Each vDocument As UpdatedDocument In vUpdatedDocuments
	Dim vTextBlox As New TextBlock With { _
		.Height = 15, _
		.VerticalAlignment = Windows.VerticalAlignment.Top, _
		.Text = vDocument.Title, _
		.Margin = New Thickness(0, vFromTop, 0, 0), _
		.Tag = vDocument _

	If vDocument.Unread Then
		vTextBlox.FontWeight = Windows.FontWeights.Bold
	End If


Here I’m creating a new textblock (some kind of mix between textbox and label in WPF), where I’m setting the .Tag property to my UpdatedDocument, so that I can use this object when for instance clicking on the textblock. And, if the document is unread, I’m setting it to Bold and then adding it to my RecentUpdates user-control.

I’ve struggled with LINQ a couple of days now, and I’m starting to get a hold of it. It’s still weird since I’m used to T-SQL, but I like the possibilities it gives me when developing. One thing I wasn’t too impressed by was the query it generated on the SQL Server though. I used profiler to check it out. It’s actually so ugly that I don’t dare to put it here 🙂 So, if you want to see it, test it yourself! Btw, to get started, Microsoft’s “LINQ To SQL Samples” is a good place to start.