Custom Expression in Linq-to-Sql Designer

Posted by csharpnoob on Stack Overflow See other posts from Stack Overflow or by csharpnoob
Published on 2010-05-03T11:45:47Z Indexed on 2010/05/03 11:58 UTC
Read the original article Hit count: 262

According to Microsoft:

http://msdn.microsoft.com/de-de/library/system.data.linq.mapping.columnattribute.expression.aspx

It's possible to add expression to the Linq-to-SQL Mapping.

But how to configure or add them in Visual Studio in the Designer? Problem, when I add it manual to thex XYZ.designer.cs it on change it will be lost.

//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:2.0.50727.4927
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

This is generated:

   [Column(Name="id", Storage="_id", DbType="Int")]
   public System.Nullable<int> id
   {
    ...

But i need something like this

[Column(Name="id", Storage="_id", DbType="Int", Expression="Max(id)")]
public System.Nullable<int> id
{
  ...

Thanks.

© Stack Overflow or respective owner

Related posts about linq-to-sql

Related posts about visual-studio-2008