Browse > Home / Archive by category 'ASP.NET'

| Subscribe via RSS

ADO.NET Entity Framework Quickstart Tutorial

June 3rd, 2008 | No Comments | Posted in ASP.NET, C#, EntityFramework, LINQ

The ADO.NET Entity framework received another update last week as part of the Visual Studio 2008 and .NET Framework 3.5 Service Pack 1 Beta, so to coincide with this I give you a quick run through to get you started. Being honest, if you have used an OR mapper in the past this will be familiar territory. If not, this new implementation is a good place to start.

screenshot1 So to begin, create a new ASP.NET website, Add New item, and then choose ADO.NET Entity Data Model. Name it EntityModel.edmx and click Add to create a new model.

The Entity Data Model Wizard will pop up and give you a chance to configure your new model. For the purposes of this walk through, choose Generate from database and click Next.

screenshot4 Set up your data connection, I won’t go into this as it’s simple enough to figure out if you’ve never done it before. Click the checkbox to save entity connection settings into your web.config and name it MyEntities.

screenshot6The wizard will then tootle off and retrieve the names of all the tables, views and stored procedures in your database. Choose a table ( I’ve chosen a table from my DB called ‘Log’ ) and name the Model Namespace MyModel.

Click Finish and the designer for your model will open. As a side note have a look at the Model Browser on the right hand side - it looks a bit ‘rendered’ for want of a better description, as though it’s drawn via GDI+ compared to the Solution Explorer….strange!

Now add a new web page and go into the code behind to start the real work. It’s just a simple bit of code to CRUD the Log entities in my database.


// instantiate a new Log entity
MyModel.Log log = new MyModel.Log();

// populate it’s properties
log.Date = DateTime.Now;
log.Exception = “Test Exception”;
log.Level = “Test Level”;
log.Logger = “Test Logger”;
log.Message = “Test Message”;
log.Thread = “Test Thread”;

//instantiate the entity ‘context’ - the object used
//as a ‘gateway’ to the DB
MyModel.MyEntities entities = new MyModel.MyEntities();

// Save the new log entity to the DB
entities.AddToLog(log);
entities.SaveChanges();

// Load it back via a little LINQ query
// ( funny how you must use .First instead of .Single )
MyModel.Log loadedLog = entities.Log .Where(ent => ent.Level == “Test Level”).First();

// make a change and save it back to the DB
loadedLog.Message = “Message has changed!”;
entities.SaveChanges();

// Finally delete the object from the DB
entities.DeleteObject(loadedLog);
entities.SaveChanges();

Notice how you have to call .SaveChanges() to persist back to the DB. That’s it! A super fast run through of CRUD with the ADO.NET Entity Framework! Enjoy!

kick it on DotNetKicks.com

Come and work for Qire in Liverpool

June 3rd, 2008 | No Comments | Posted in ASP.NET, C#

Qire LogoFancy coming to work in Liverpool - European Capitol of Culture 2008 - to build the next generation of voice driven applications?
Qire is the acknowledged leader in intelligent voice messaging systems with many top notch public and private sector clients.
We create applications that manage security, business process and call centre automation via the power of ASP.NET and C# ( plus some other exciting technologies that you can learn on the job ). We are looking for a permanent mid/high level developer to join our small team of happy coders to help shape the future of telephony. You will be adept at asp.net c# sql, have good soft skills and want to work in a friendly and creative coding environment. If you are interested, send me note ( or even better a link to your CV) via the contact form on this site.

EXTJS Functionality in ASP.NET

February 22nd, 2008 | No Comments | Posted in ASP.NET

Be sure to check out the new Coolite library that brings the awesome EXT javascript UI framework to the ASP.NET platform.
Go Here

Microsoft Exam 70-528 : Passed!

January 15th, 2008 | No Comments | Posted in ASP.NET

Today I finished my last exam - 70-528 Microsoft .NET Framework 2.0 - Web-based Client Development, and passed with a score of 985. That means I am a Microsoft Certified Professional Developer : Web Applications and Microsoft Certified Technology Specialist in ASP.NET.
The exam I took today was pretty easy to be honest and would not present much of a challenge to developers who make a living coding in ASP.NET. I didn’t revise much at all for this one…maybe about 10 hours total brushing up on a few minor points, and finished the test in about 25 minutes.
If you want a decent measure of your coverage of the framework you could do worse than go for the MCPD and MCTS. I enjoyed the journey very much.

Developer Highway Code - Microsoft Security Best Practice eBook

January 9th, 2008 | No Comments | Posted in ASP.NET, Framework

  highwaycodeMicrosoft have put together a nice little manual that sets out best practice for developer driven security. It’s choc full of techniques you can integrate into your development pursuits to build better, more secure applications.

From the official Microsoft blurb: To build software that meets your security objectives, you must integrate security activities into your software development lifecycle. This handbook captures and summarises the key security engineering activities that should be an integral part of your software development processes.
Download full book as a .pdf by clicking here

Liverpool ASP.Net Bloggers - A Reading List

January 8th, 2008 | 2 Comments | Posted in ASP.NET

This is a list of Liverpool based blogs that write about ASP.Net every now and then that I read. Nothing more than that!

Steve Clayton: Geek In Disguise
Jonswain’s Weblog
paulpierce.co.uk
ts0
MJJames - Web Developer
Reflective Perspective
Paul Kinlan

If you want to be added or removed from this list for any reason, just drop me a line and I’ll attend to it.

Microsoft Exam 70-536 : Passed!

January 7th, 2008 | No Comments | Posted in ASP.NET

I took my second Microsoft cert today, the 70-536 Microsoft .NET Framework 2.0 - Application Development Foundation, and passed with a score of 1000. I’m pretty chuffed again. This exam was much more difficult and more  than the 70-547 I passed before Christmas. There were lots of questions that you either knew the answer to, or you didn’t. I had spent a lot of time revising constructors and overloaded constructors to common .Net classes and it certainly paid off. I revised quite a bit of the holiday period using the Microsoft training kit mentioned in my previous exam post.

So only one exam to go until I am MCPD and it seems to be the easiest exam of the set, so I am not going to revise at all and just take my chances on the day. I am planning to take it this time next week and will update here on my progress.

End of 2007 Roundup

December 31st, 2007 | No Comments | Posted in ASP.NET

Well it’s been a fantastic year for me and mine so I’m just going to welcome a new year ( Liverpool Capital of Culture 2008 no less )  in with a bit of a recap and a few 2007 highlights.

Books of the Year
Programming WCF Services is the most authoritative textbook on Microsoft’s latest communication methodology. A great resource book that I have returned to again and again.

Non-Tech Books of the Year
Lexicon Devil: The Short Life and Fast Times of Darby Crash and the Germs is a fantastic word of mouth recount of the early days of the LA punk scene.
House of Leaves: Spooky shape shifting architecture story told in experimental prose. Most innovative book I’ve read for years.

Album of the Year
Panda Bear - Person Pitch is hands down winner. Super tight Beach Boys style harmonies over clever loops makes for a seductive mix. No hiphop in my end of year list. It’s been the worst year EVER for rap in my mind - even the new Wu, or Big Doe Rehab just don’t make the grade.

Booze of the Year
Both Makers Mark and Knob Creek have been well received around my way!

Event of the Year
The arrival of my daughter Kitty has been the most life affirming thing I have ever experienced. She is so clever and surprises me with new stuff every day. I’m so proud!

Next Year
I work with some pretty cool and clever people at Qire, it’s a great environment to make software in. We are doing cutting edge IVR stuff and gaining more prestigious clients every day. Next year we have some pretty tough targets to meet, but I’m going to do my damndest to make sure we get there. Also, I’m going to get right into VS 2008 and attempt to pass a couple more Microsoft certs.

That’s it! Have a happy new year!

Microsoft Exam 70-547 : Passed!

December 17th, 2007 | No Comments | Posted in ASP.NET

I took the Microsoft 70-547 Designing & Developing Web-Based Applications Using the Microsoft .Net Framework examination today and passed with a score of 900 out of 1000. I’m pretty chuffed to be honest. This is the first MS cert I’ve taken, but it has given me the bug to take a few more. I would recommend it to anyone.
If you are googling this page and want some tips on how to pass this exam, I would say that the MCTS training kit from Microsoft is a must: the entire content of the exam was explained in this book. I studied for a month, about 2 hours a day, and cleared the exam in about 20 minutes.
It’s my birthday later on in the week, and Christmas is just around the corner. Passing the exam has put me in a celebratory mood!

Is it too late to say I love jQuery too?

November 5th, 2007 | No Comments | Posted in ASP.NET, Ajax

jQuery is lightweight javascript framework with lots of support on the net and a big library of plug ins. Given the amount of client side content that is going to be knocking around in Visual studio 2008, I’d say it’s a good time to brush up on your jscript skills. While you are at it, make sure you check out this library to give you a leg up. Communication between jQuery and ASP.NET is a breeze and as a quick example, this is what you need to get inline editing going with very little effort at all.

You will need:
jQuery
jEditable

First the .aspx
<%@ Page Language=“C#” AutoEventWireup=“true” CodeFile=“Default.aspx.cs” Inherits=“_Default” %>
 <!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=“http://www.w3.org/1999/xhtml”><head runat=“server”>
<title>Untitled Page</title> 
<script src=“jquery.js” type=“text/javascript”></script> 
<script src=“jeditable.js” type=“text/javascript”></script> 
<script type=“text/javascript”>$(document).ready(
function(){ $(“p”).editable( “http://localhost:3684/test/handler.ashx”, { type: ‘textarea’,cancel: ‘Cancel’,indicator:“test.jpg”, submit:‘ok’});
});</script>
 </head>
<body>
<form id=“form1″ runat=“server”>
<div>
</div>
<p>yes you are now rocking with the best</p>
</form>
</body>
</html>

 

and you will need a httphandler to save the edits. For this example, I’m just writing the data back out without storing it.

<%@ WebHandler Language=“C#” Class=“handler” %> using System;using System.Web; public class Echo : IHttpHandler {public void ProcessRequest (HttpContext context) {context.Response.ContentType = “text/plain”;context.Response.Write(context.Request.Params["Value"]);}public bool IsReusable {get {return false;}} }

 

And that’s it. Inline editing with jQuery and ASP.NET. Simple!

PS if you want to know why there has not been much action on the blog this month, blame this.