Retrieving SQL Type Image Using LINQ

LINQ views the Image type in SQL Server as Binary. So, there are a few options that we have. We can either (a) modify our LINQ to SQL class and change the property to Byte() instead of Binary or we can (b) convert the Binary to an array. To do the latter, you can use a lambda expression to obtain the image you are looking for and grabbing just the image. Here’s an example: MySqlContext.Photos.Single(Function(p) p.PhotoID = PhotoID).OriginalBytes.ToArray The above assumes that we have a table called Photos that contains a column called PhotoID. We’ll filter the PhotoID (p.PhotoID) based … Continue reading Retrieving SQL Type Image Using LINQ

ASP.NET MVC Preview 3 Announced

Scott Guthrie just posted about the 3rd preview of the ASP.NET MVC over on his blog. You can catch the full details here: http://weblogs.asp.net/scottgu/archive/2008/05/27/asp-net-mvc-preview-3-release.aspx.

Attention Twitter: Wise up!

I read through the Twitter blog from time to time just to see how things are going. Apparently, things aren’t going good. Pagination and IM updates have been temporarily disabled and something has caused my twitter utilities (twhirl and OutTwit) to cease function. I keep getting an error that shows "Rate limit exceeded. Clients may not make more than 30 requests per hour." Can you imagine if Twitter was an eCommerce shop and stopped a viewer after 30 page views? They’d slowly lose business. Does the Twitter team get that? What about the limit of 140 characters? I know plenty … Continue reading Attention Twitter: Wise up!

Force Your Web Site To Be IE7 Compatible

Microsoft recognizes that it will be difficult to have all sites use the latest HTML and CSS specs that are found in IE8. To accommodate the web sites that cannot be converted at this time, they’ve created a work around. There are two options: a) you can modify the config in IIS 7 or b) you can add a new meta tag to your page headers. More information about this can be found by visiting http://support.microsoft.com/kb/952030.

SQL Management Studio Shows All Databases

This has "bugged" me for awhile. When you log into any version of SQL (2000, 2005, and even 2008) as a user with restricted access to just a single database (or even a few databases), you can still see a complete list of all the databases on that server. There have been times when I needed to share a database with a customer or have accessed a shared database at a host such as DiscountASP.net or GoDaddy and can see all of the customers on that one box. It’s more of a nuisance than a real threat but I really … Continue reading SQL Management Studio Shows All Databases

Using "Like" in LINQ to SQL

I’ve recently discovered that LINQ and VB can be confusing. I was attempting to pull the top 10 rows of a table where the column started with ‘W’. You’d think after I typed that, I’d figure out the solution. That’s not the case. Instead, I struggled. Here’s what I originally came up with: Dim q = From t In db.Employees Where t.LastName Like prefixText & "%" Select t.LastName Take count Little did I realize that the Like operator in my query was the VB Like operator. So, I had to modify my lambda expression to this: Dim q = From … Continue reading Using "Like" in LINQ to SQL

Using LINQ to SQL and ConnectionStrings in a Class Library

I was looking to separate my LINQ to SQL data layer from the rest of my application. So, I decided to move the files to a class library. This way, when my application builds, all of my LINQ files are found in MyApp.DL or something similar. However, I wanted the class library to use the SQL connection that I have set in my web.config. Because the class library does not have a reference to System.Configuration, I had to add that first. I then created a partial class for my Context object. Inside, I created a new constructor with a boolean … Continue reading Using LINQ to SQL and ConnectionStrings in a Class Library

Obtain the Identity of a New Row Using LINQ

It’s actually pretty easy and user friendly to obtain the value of the identity column using LINQ. After you create your object and insert it on submit, you can call the identity column’s property on your object. For instance: Dim db As New BlogDataContext() db.BlogPosts.InsertOnSubmit(MyPost) db.SubmitChanges() Dim IdentityValue As Integer = MyPost.PostID In this example, the IdentityValue variable would be assigned to the PostID of the post that was just submitted.

3G iPhone will Come In June

According to Gizmodo, the iPhone 3G launch date will be June 9th. It will be interesting to see what further market share the iPhone will capture with this latest phone. I know many individuals have held out from purchasing an iPhone because of the lack of 3G support. It will also be interesting to see what phones other providers will release to compete with the iPhone. For more details, visit http://tinyurl.com/5pe7pc.

Philly.net Code Camp #2

The second Philly.net Code Camp will be held tomorrow. Roughly 600 attendees will get to see some great talks in 8 different tracks. For more information about the event, check out http://tinyurl.com/5t7qdw.