Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 368305
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T13:48:40+00:00 2026-05-12T13:48:40+00:00

I’m using a shim property to make sure that the date is always UTC.

  • 0

I’m using a shim property to make sure that the date is always UTC. This in itself is pretty simple but now I want to query on the data. I don’t want to expose the underlying property, instead I want queries to use the shim property. What I’m having trouble with is mapping the shim property. For example:

public partial class Activity
{
    public DateTime Started
    {
        // Started_ is defined in the DBML file
        get{ return Started_.ToUniversalTime(); }
        set{ Started_ = value.ToUniversalTime(); }
    }
}


var activities = from a in Repository.Of<Activity>()
                 where a.Started > DateTime.UtcNow.AddHours( - 3 )
                 select a;

Attempting to execute the query results in an exception:

System.NotSupportedException: The member 'Activity.Started' has no supported 
translation to SQL.

This makes sense – how could LINQ to SQL know how to treat the Started property – it’s not a column or association? But, I was looking for something like a ColumnAliasAttribute that tells SQL to treat properties of Started as Started_ (with underscore).

Is there a way to help LINQ to SQL translate the expression tree to the Started property can be used just like the Started_ property?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T13:48:40+00:00Added an answer on May 12, 2026 at 1:48 pm

    There’s a code sample showing how to do that (i.e. use client-side properties in queries) on Damien Guard’s blog:

    http://damieng.com/blog/2009/06/24/client-side-properties-and-any-remote-linq-provider

    That said, I don’t think DateTime.ToUniversalTime will translate to SQL anyway so you may need to write some db-side logic for UTC translations anyway. In that case, it may be easier to expose the UTC date/time as a calculated column db-side and include in your L2S classes.

    E.g.:

    create table utc_test (utc_test_id int not null identity,
      local_time datetime not null,
      utc_offset_minutes int not null,
      utc_time as dateadd(minute, 0-utc_offset_minutes, local_time),
      constraint pk_utc_test primary key (utc_test_id));  
    
    insert into utc_test (local_time, utc_offset_minutes) values ('2009-09-10 09:34', 420); 
    insert into utc_test (local_time, utc_offset_minutes) values ('2009-09-09 22:34', -240);   
    
    select * from utc_test
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.