Business not as usual

by Pascal Parent 19. January 2010 23:07

Many things to say, so I’ll restrain myself to say that I am in business for myself now, as seen in my previous post, and that you will soon have another site to track, since I do not have the name for it yet, I cannot give you a URL, but it will be targeted at the SOHO and small businesses and how to leverage and make good use of the web, since that is what my company is partially about and it will be my company’s site.

The other piece of good news is that I will start developing again and thus writing more often I hope.

The game is afoot ;-)

Digg It!DZone It!StumbleUponTechnoratiRedditDel.icio.usNewsVineFurlBlinkList

Tags:

News

by Pascal Parent 19. January 2010 22:59

Firstly, Season’s Greeting to all.

I know I have been absent since the 1st of December of last year, I apologise but let me explain…

Firstly, I was retrenched by mutual consent with my company, I had not done much in a while and did not feel I was adding any value, so it was decided that since I did not fit anywhere else I would take a volunteery retrenchment and go on my marry way, all this before Christmas. For a while there, I got a little depressed but I have been trough worst and picked myself up and continued actively looking for a new job. That did not go well either, it felt more like I was being tested like a kid out of school then anything else and to be honest most of my prospective employers were looking for code monkeys, I am a Senior Developer / Architect, note the “developer” part. A developer is a solution provider not what I call a code monkey or a programmer whom just types away and hopes that the BRS is correct. So my job hunting efforts came to an abrupt end. I’d still like to thank Kirstin Garland and Jason Pretorius for all their effort, guys I know you did your best. I got depressed again…

So where from here?

Well, that was the hard choice, become a code monkey and be on antidepressants all my life or take a leap of faith?

I took a leap of faith, I have a fair severance package so why not open my own Web Development House? One that focuses on SOHO to small businesses I could bring a lot to the table, more than web sites I have learned so much about how to make use of the web to enhance businesses why not merge both skills into one and create a company that offers not websites but rather a way to improve businesses using the web as a medium, after all I have been doing it for more that 10 years for small businesses to large corporate. So, an old dream of mine was born, Panache Web and Business Development. We will start operating mid January and oddly enough my first client is my old company, which in many ways is great.

Unfortunately, my woes did not stop at being retrenched…

My camera, a Canon EOS 400D, attempted a dare devil swim in the dog bath along with my flying laptop. My dog, an Alaskan Malamute, decided that whilst I was outside with him it would be a great time to give me a big hug, the results were less 1 SLR and less 1 laptop. Thanks to Outsurance that was sorted rather fast and efficiently.

I replaced my Canon EOS 400D with, dare I say it, the mighty Canon EOS 7D, if you have been following me on Twitter you would know what I initially thought of the 7D, it’s like going from a bicycle with training wheels (the 400D) to a superbike (the 7D). My head is still trying to adjust, I’ll talk more about the mighty 7D in another post, hopefully with some image samples. to tell the truth, I have read the manual cover to cover twice and I am about to do it again but enough about the incredible 7D… I have also decided to take some photography courses starting at the end of the month trough to March, I would like to open a small studio and my skill set though not bad for a junior amateur is nothing compared to what I will need to have a studio, but there will be more about that in the coming month too.

Lastly, I have replaced my laptop, an HP Pavilion dv6000 series with, no not an Apple Notebook as I originally thought since the Apple did not have my requirement for my development work (in .NET) so I did some research and voila I am the proud owner of a Dell Studio XPS 16 and all I’ll say is, wow. It sorted out both my development and photographic requirements in one go (not to mention it’s gaming abilities). The only two issues with it are it’s weight, it’s really heavy, and the HD screen, yep you read right it has a 1920 by 1080 native resolution on a 16.1 inch screen, you need a magnifying glass to read the screen. OK it’s also an advantage most of the time, pair it with a 24 inch HD screen and problem solved, yes it can handle it and so much more…

So there is the story so far… More to come soon…

[Cross-posted for www.onlyinsouthafrica.com]

Digg It!DZone It!StumbleUponTechnoratiRedditDel.icio.usNewsVineFurlBlinkList

Tags:

General

Dealing with foreign key with ADO.NET Entity Framework and Linq-to-Entities

by Pascal Parent 23. August 2009 13:24

We all know by now that table foreign keys are not directly accessible in Entity Framework and that searching on the subject on Google or Bing brings confusion and despair, at least it did to me. MSDN was not better, so I decided to go the trial and error route instead and I was not sorry.

I have found that, as with the .NET Framework, Linq often has a 1 liner solution to a problem, so my attitude was simple: find it. And so I did.

The trick is resolved with a simple and non-obscured object and it looks like this:

Entity.Reference.EntityKey = new EntityKey("Entities.Entity", "ReferencedColumn", "Value"));

Oddly enough, and contrary to what I have read, this command works for inserting, editing and deleting the foreign key. There are some caveats though, if you want to be able to delete the key, you’ll have to have the field / property nullabe in both the database and object.

Here is how I typically handle an insert, edit, delete situation:

 

private void Save(int ID)
        {
            try
            {

                int _id = Convert.ToInt32(ID);

                using (ObjectEntities db = new ObjectEntities())
                {
                    //Add a new object
                    if (_id == 0)
                    {
                        var _object = new object();

                        _object.Name = this.txtName.Text.Trim();

                        if (String.IsNullOrEmpty(this.SomeDropDown.SelectedItem.Value) == false)
                        {
                            _object.EntityReference.EntityKey = new 
EntityKey("ObjectEntities.Entity", "ID", Convert.ToInt32(this.SomeDropDown.SelectedItem.Value)); } else { _object.EntityReference.EntityKey = null; ; } //Some additional variable assignement db.AddToEntity(_object); db.SaveChanges(); // Rebuild the Grid // return to the list } else //Edit the object { var _object = ((from Item in db.Entity where Item.ID == _id select Item) .FirstOrDefault()); _object.Name = this.txtName.Text.Trim(); if (String.IsNullOrEmpty(this.SomeDropDown.SelectedItem.Value) == false) { _object.EntityReference.EntityKey = new
EntityKey("ObjectEntities.Entity", "ID", Convert.ToInt32(this.SomeDropDown.SelectedItem.Value)); } else { _object.EntityReference.EntityKey = null; ; } db.SaveChanges(); // Reload the current item with the changes } } // Do some logging } catch (Exception ex) { //Output some message about the error. } }

And that is all the is to it.

Related Links:

http://msdn.microsoft.com/en-us/library/dd283138.aspx 

http://msdn.microsoft.com/en-us/library/system.data.objects.dataclasses.ientitywithkey.entitykey.aspx

Digg It!DZone It!StumbleUponTechnoratiRedditDel.icio.usNewsVineFurlBlinkList

Tags: , ,

General

More Linq-to-Entities – Simple create,edit, delete

by Pascal Parent 21. July 2009 16:30

I was searching the net for a simple example of a create,edit, delete with Linq-to-Entities, I eventually found but it was too elaborate, so I thought I would give my 2 cents worth and give a simple example. When I embarked on my learning mission of Linq-to-Entities it was to simplify my life, sometimes I wonder if this was the case, I still love Linq though.

Creating a new record is as easy as this:

using (DataEntities db = new DataEntities())
{
//Create a new NewsItem
var newsItem = new NewsItem();
//Assign values	
newsItem.Headline = this.txtHeadline.Text.Trim();
newsItem.PublishedDate = Convert.ToDateTime(this.txtPublishDate.Text.Trim());
newsItem.Active = this.cbActive.Checked;
newsItem.Synopsis = this.txtSynopsys.Text.Trim();
newsItem.Content = this.edContent.Text;
newsItem.Author = this.txtAuthor.Text.Trim();
//Add the new item to the set 
db.AddToNewsSet(_news);
//Commit the changes
db.SaveChanges();
}

Editing a record is slightly more complicated, first you have to have the record if it is not persisted as is the case in ASP.NET.

using (DataEntities db = new DataEntities())
{
//Get the NewsItem for editing
var newsItem = ((from NewsItem in db.NewsSet
where NewsItem.ID == newsID
select NewsItem)
.FirstOrDefault());
//Assign values	
newsItem.Headline = this.txtHeadline.Text.Trim();
newsItem.PublishedDate = Convert.ToDateTime(this.txtPublishDate.Text.Trim());
newsItem.Active = this.cbActive.Checked;
newsItem.Synopsis = this.txtSynopsys.Text.Trim();
newsItem.Content = this.edContent.Text;
newsItem.Author = this.txtAuthor.Text.Trim();
//Commit the changes
db.SaveChanges();
}

Lastly, deleting a record

using (DataEntities db = new DataEntities())
{
//Get the NewsItem for editing
var newsItem = ((from NewsItem in db.NewsSet
where NewsItem.ID == newsID
select NewsItem)
.FirstOrDefault());
//Set the record for deletion from the database
db.DeleteObject(newsItem); 
//Commit the changes
db.SaveChanges();
}

As can be seen there are no complications and Linq just does it.

In my next Linq article I will be talking about relational data editing.

Digg It!DZone It!StumbleUponTechnoratiRedditDel.icio.usNewsVineFurlBlinkList

Tags: , ,

ASP.NET | Database

Installing Microsoft Windows Vista SP2 .NET development machine

by Pascal Parent 26. June 2009 15:29

With a new job comes a new machine and as with all new machines an installation is required. I thought it would be nice to document it as I had done with installing a Microsoft Windows XP development machine previously, an article I seem to have lost in a blog move.

The first issue at hand is whether to use the 32 or 64 bit version of Vista, the answer is both easy and overly complicated, so let me simplify… If you have less or equal to 3GB of RAM go for the 32 bit. From 3GB onwards, the 64 bit is a requirement to be able to use the memory above 3GB. I have installed the 64 bit on machines with 2GB of RAM without any adverse effect, a good option if you want to upgrade your RAM later. As for the edition, Business will be your choice because you will need IIS and it’s only available for Business onwards and I find Ultimate bulky and gimmicky, see here for details.

For recommendations on machine specifications go here and here where I discuss this in length.

From here is my check list and installation sequence with a couple of notes.

  1. Microsoft Windows Vista Business
    Don’t forget to add everything IIS but to exclude FTP as you will want to install FTP 7.0 via Microsoft Web Platform Installer, also add Message Queue Server and remove the Tablet PC components if you do not have a Tablet PC. 
    1. Microsoft Vista Service Pack 1
      To my surprise, you cannot install Microsoft Vista Service Pack 2 until Microsoft Vista Service Pack 1 is installed
    2. Microsoft Vista Service Pack 2
    3. Network drivers if required
    4. Windows updates, include the Live tools so you can Blog too ;-)
    5. Balance of drivers as required
    6. Daemon Tools Lite, very important if like me you have a ton of ISOs on a portable hard drive.

At this time an Anti-Virus is a good idea, I personally recommend Symantec’s Norton Internet Security but if you are cash strapped AVG Free will do the basics.

  1. Microsoft Office 2007 Professional
    1. Microsoft Office 2007 Service Pack 2, Service pack 1 is not required in this case.
    2. Windows updates
  2. Microsoft Visio 2007
    1. Microsoft Visio 2007 Service Pack 2
    2. Windows updates
  3. Microsoft SQL 2008 Developer Edition complete installation.
    1. Microsoft SQL 2008 Service Pack 1
    2. Windows updates
  4. Microsoft Visual Studio 2008 Professional
    Exclude Microsoft SQL 2005 Express 
    I’ll talk about the add-ons and tools I use for development in another post.
    1. Microsoft Visual Studio 2008 Service Pack 1
    2. Windows Updates
  5. Microsoft SQL 2008 Express Service Pack 1
  6. Tools
    1. Paint.NET
    2. CCleaner
    3. Defraggler
    4. Virtual Box, my favourite PC emulation tool.
    5. Filezilla for FTP
    6. WinMerge for comparing files
    7. Microsoft Web Platform Installer come in handy to install all those IIS add-ons and extra apps.
    8. For PHP and MySQL installation refer to the tutorials on http://www.trainsignaltraining.com, follow the Windows Server 2008 tutorials as they are identical for Vista. These are the best I found on the net.
      1. IIS 7: Install FastCGI & PHP on Server 2008
      2. Install MySQL on IIS7 Server 2008
      3. Install PHPMyAdmin on IIS7 and Server 2008
      4. IIS7: URL Rewrite Extension on Windows Server 2008
      5. And for setting up your Wordpress blog before putting it live:
        1. Installing WordPress on IIS 7 – Part 1
        2. Installing WordPress on IIS7 – Part 2
    9. Tweetdeck for Twitter and Facebook

And there is my skeleton development installation sequence and checklist.

I hope this will help you.

Digg It!DZone It!StumbleUponTechnoratiRedditDel.icio.usNewsVineFurlBlinkList

Tags: , , , ,

General

New job

by Pascal Parent 9. June 2009 12:33

I started a new job a week ago, so expect my posting rate to decrease in the immediate future. I’ll get back to technical blogging soon enough.

For my photographic and other blogging, go to www.onlyinsouthafrica.com

Digg It!DZone It!StumbleUponTechnoratiRedditDel.icio.usNewsVineFurlBlinkList

Tags:

General

Social Networks and I

by Pascal Parent 3. June 2009 16:01

I feel the need to clarify my stance towards Social Networks, I hate them, really I do. But in this day and age if you are not on Facebook, LinkedIn and something like Digg or Technocrati you are no one. I do believe in blogs and by the nature of it Twitter, neither are “blocked” to a subscription system of sorts, so to me it is far friendlier, I only login to Facebook and LinkedIn when I get a mail telling me there are messages.

So you may ask how are my Facebook and LinkedIn accounts so active, its bacause both of my accounts are linked to both my Blogs RSS, Twitter and Flickr accounts and that is my kung-fu.

I update Twitter with TweetDeck and my websites with Windows Live Writer, both are stable and now Tweedeck also pulls info from Facebook, check them out.

Unfortunately “Social Networks” are a necessary evil in my life, so I live with it.

Cross-posted from Only in South Africa .COM

Digg It!DZone It!StumbleUponTechnoratiRedditDel.icio.usNewsVineFurlBlinkList

Tags:

General

JQuery Validate plugin to validate a ASP.NET Form

by Pascal Parent 25. May 2009 09:30

The first time I used the JQuery Validate plugin, it did not work at all, see JQuery Validate odd behaviour with the ASP.NET Script Manager for reason, but perseverance and stubbornness prevailed and I finally created my first JQuery validated ASP.NET Forms contact form. There are a lot of examples out there, though for some odd reason I can never find a decent example of anything to do with ASP.NET Forms and JQuery, so I battled it out.

First and foremost, when using JQuery with forms the this.object.ClientID function is your second best friend, your best friend is the fact that you can have more than one CSS class descriptor in one class, for example the following CssClass="required email" is completely valid, thanks to JQuery’s CSS Selector. This means the you do not have to know the object’s name and that the same behaviour can easely be set to more than one object with ease.

But I digress, though I must be honest I am still learning a lot about JQuery’s ability to make my life easier every day.

The initiation code is simple enough:

<asp:ScriptManager ID="ScriptManagerProxy1" runat="server">
<Scripts>
<asp:ScriptReference Path="~/Assets/Javascript/jquery.validate.pack.js" />
     Scripts>
asp:ScriptManager>
<script language="javascript" type="text/javascript">
     $(document).ready(function() {
$('.error').hide();
$('#<%= this.Page.Form.ClientID %>').validate();
});
script>

A few things worth noticing, I use the ScriptManager for relative path (the ~/ thing), this eases the problems related to maintenance and moving the ASP.NET file will cause no adverse effect, so if like me you want to refactor the path, it’s not an issue. I also hide all error text $('.error').hide() it is recommended to hide any object wit the .error Css selector prior to use. And then register the validation methods where I use this.object.ClientID to ensure that the right object is called, since I make use of MasterPages this is essential.

From here things get even easier, apply the required validation on the object

<asp:TextBox ID="txtEmail" runat="server" CssClass="required email">asp:TextBox>

Though not required, I would advise that, as a standard, the first CSS selector have an actual class in the CSS file. I also set a default class to all of my inputs.

For further built-in and custom validation requirement please head over to JQuery Validate plugin page where you will find the documentation.

Digg It!DZone It!StumbleUponTechnoratiRedditDel.icio.usNewsVineFurlBlinkList

Tags: ,

ASP.NET

JQuery Validate odd behaviour with the ASP.NET Script Manager

by Pascal Parent 24. May 2009 13:06

I discovered the JQuery Validate plugin a while back and could never get it to work in ASP.NET until today and though I have no idea why this the code bellow does not work.

<asp:ScriptManagerProxy ID="ScriptManagerProxy1" runat="server">
    <CompositeScript>
        <Scripts>
            <asp:ScriptReference Path="~/Assets/Javascript/jquery.validate.pack.js" />
        Scripts>
    CompositeScript>
asp:ScriptManagerProxy>

If the extension is in the <CompositeScript> section it does not work, I will try to figure out why later but if it is removed from the <CompositeScript> it start to work again.

So the resultant code will look like this:

<asp:ScriptManagerProxy ID="ScriptManagerProxy1" runat="server">
    <Scripts>
       <asp:ScriptReference Path="~/Assets/Javascript/jquery.validate.pack.js" />
    Scripts>
asp:ScriptManagerProxy>
I honestly say that the JQuery Validate plugin is the best validation package I have come across in a while, go and get it.
Digg It!DZone It!StumbleUponTechnoratiRedditDel.icio.usNewsVineFurlBlinkList

Tags: ,

General

Typemock Is Launching The ASP.NET Bundle – Get Free Licenses

by Pascal Parent 19. May 2009 06:59

Unit Testing ASP.NET? ASP.NET unit testing has never been this easy.

Typemock is launching a new product for ASP.NET developers – the ASP.NET Bundle - and for the launch will be giving out FREE licenses to bloggers and their readers.

The ASP.NET Bundle is the ultimate ASP.NET unit testing solution, and offers both Typemock Isolator, a unit test tool and Ivonna, the Isolator add-on for ASP.NET unit testing, for a bargain price.

Typemock Isolator is a leading .NET unit testing tool (C# and VB.NET) for many ‘hard to test’ technologies such as SharePoint, ASP.NET, MVC, WCF, WPF, Silverlight and more. Note that for unit testing Silverlight there is an open source Isolator add-on called SilverUnit.

The first 60 bloggers who will blog this text in their blog and tell us about it, will get a Free Isolator ASP.NET Bundle license (Typemock Isolator + Ivonna). If you post this in an ASP.NET dedicated blog, you'll get a license automatically (even if more than 60 submit) during the first week of this announcement.

Also 8 bloggers will get an additional 2 licenses (each) to give away to their readers / friends.

Go ahead, click the following link for more information on how to get your free license.

Digg It!DZone It!StumbleUponTechnoratiRedditDel.icio.usNewsVineFurlBlinkList

Tags:

General

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2010 The ASP.NET Guy