Home » c# » Computed Columns Using LINQ to SQL Classes

Computed Columns Using LINQ to SQL Classes

Last week we looked at the extension points Microsoft has wired into the LINQ to SQL classes and how they can be used to achieve some of the capabilities of the Business Logic Layer (BLL) in a multi-layered architecture.

We saw that this feature allowed us to modify data as it was coming out of the database up to the presentation layer and from the presentation layer down to the database.  But, what about the times when what you really want is another field in your row that is based on the other fields in your database?

You actually have two choices.  You could create a SQL statement that computes the columns for you.  Or you can add a property to your LINQ to SQL classes that computes the value for you.

 

Other post in c#

Related Post

  • Object Initialization in CSharp 3.0 and VB.NET 9Object Initialization in CSharp 3.0 and VB.NET 9 Yesterday we looked at the new var keyword in CSharp.  This makes CSharp variable declaration similar to VB.  After all, they've had the DIM keyword for years which essentially does the […]
  • CSharp adds the var keyword!CSharp adds the var keyword! There have been several new features added to the CSharp language that will significantly reduce the amount of code that ends up in our source files.  It will not significantly reduce the […]
  • DataSets, ObjectDataSource and 3-Tier ASP.NETDataSets, ObjectDataSource and 3-Tier ASP.NET As I've mentioned in other post, while I think LINQ has it's uses, I still favor the use of the ObjectDataSource control in conjunction with DataSets and a 3-tiered architecture.  Since […]
  • Simple Properties in C# 3.5Simple Properties in C# 3.5 It's such a little thing.  But, how much of our CSharp code looks something like this: private string _propertyName;public string PropertyName { get { […]
  • SQL For Programmers – Finding a StringSQL For Programmers – Finding a String Many times in our queries, we aren't looking for an exact match.  We are looking for one string that exists in another.  There are a couple statements available to us that will allow us […]

About Dave Bush

Dave Bush is a Full Stack ASP.NET developer focusing on ASP.NET, C#, Node.js, JavaScript, HTML, CSS, BootStrap, and Angular.JS.Does your team need additional help in any of the above? Contact Dave today.