| Very Quick Guide To DLinq: Part 2 | Posted on Tuesday, March 25, 2008 at 2:45 AM | In this part I'm going to take a look at inserts, updates and deletes using DLinq.
The Overall Model
First, to make changes to a database, you instantiate the data context object, just as we did before doing selections in the previous part.
var DB = new ResourcesDB();
You then do the required changes; we'll look at this part in just a moment. However, the inserts, updates and deletions are not performed immediately. They do not take place until you explicitly submit the changes:
DB.SubmitChanges();
This means that you can make many changes, then send them to the database all at once.
Inserting Data Into A Table
To make a single new entry to a database table, use the InsertOnSubmit method on the Table object. This takes a single parameter: an instance of the object that represents a row in the the table. You can use the object initializer syntax to write this very neatly.
DB.BookResources.InsertOnSubmit(new BookResource()
{
Read More |
| Very Quick Guide To DLinq: Part 1 | Posted on Friday, March 14, 2008 at 9:10 AM | We have already written about using Linq, but didn't cover DLinq. This post takes a quick look at getting started with DLinq, which allows you to write Linq queries against databases. Once you're up to speed, you can take a database and be writing Linq queries against it in under five minutes!
In future parts in this series of posts, we'll look at doing database updates, writing more complex queries and debugging. In this one, we'll just look at doing some simple queries.
Creating The Linq to SQL Classes
The bad news is that before you can use DLinq, you have to create Linq to SQL classes to represent your database tables. The good news is that Visual Studio 2008 (aside from the Express Edition) can do all of the hard work for you in this.
Read More |
| Float, Double and Decimal: do you know the differences? | Posted on Tuesday, March 11, 2008 at 3:17 AM | There are a number of data types available in the .Net framework for storing numbers with fractional parts. They are each appropriate for different situations, and using the wrong one can lead to errors in calculations.
Thinking About Accuracy
In some applications, you require that calculations involving numbers with fractional parts are exact. Examples of this are in financial applications, where losing the odd cent here and there in a calculation is unacceptable. Customers expect their accounts to be completely accurate, not to mention the tax man.
In other applications, you don't care about exact results, but you are interested in having an answer that is correct to a certain number of significant digits. This is the case in experimental physics, for example. When you make a measurement of something, you can only measure it as accurately as your equipment will allow you. Therefore, you have an inherent error in that value already, which is going to cascade through any calculations you do with it. This means that while your computed answer may be 5.1826, you may know that the values this answer was calculated from were only accurate to three significant digits, and so the last two digits in this result (the 0.0026) don't matter. If there is a computational error in them, so be it - it's not going to hurt us.
Read More |
| Can a language make programming more fun? | Posted on Monday, March 03, 2008 at 7:38 AM | I've programmed in a range of languages. There are some that I really enjoy coding in, there are some I can put up with and there are some that frustrate and bore me. Having an interest in language design, I got somewhat curious about what it is that makes working with some languages more enjoyable than others.
A couple of questions came to me right away. First, there is probably a lot of personal preference here. What makes a language enjoyable for me to work in may well be what makes it frustrating to someone else, and vice versa. Second, languages are tools. I've said often enough that different languages are suited to different tasks, and you should pick the one that best fits the job at hand. How important a factor is whether one enjoys working in the language when trying to choose whether to use it in a project or not?
Personal Preference
Read More |
|
Subscribe
RSS Feed
By Tag
.NET Algorithm alpha five C# C# 3.0 DLinq Higher Order Programming Java Lambda Expressions Linq Linux MySQL Performance Perl Programming SSH Test Driven Develoment Testing Threading UNIX
By Month
April 2008
March 2008
February 2008
January 2008
December 2007
November 2007
October 2007
Help
Check out the Blog FAQ.
|