On Tue, Apr 20, 2010 at 8:19 AM, comicrage <[email protected]> wrote:
> Hi,
>
> I am learning the generated LINQTOSQL entity class. Everything worked
> until I added 2 datetime variables as folllowed. I passed the data
> object from client to WCF and back to SQL Server. I wanted to add two
> extra datetime parameters, which are not in the database table. The
> idea is to perform a date range query agaisnt the timestamp
> transaction datetime. When I added the start and end datetime, I get
> a .StartDateTime has no supported translation to SQL error. How can I
> fix this issue in the DataContent/Data model class to perform the
> query?
>
> Thanks
>
>        private System.DateTime _StartDateTime;
>
>        private System.DateTime _EndDateTime;
>
>        public System.DateTime StartDateTime
>        {
>            get { return this._StartDateTime; }
>            set
>            {
>                if ((value != null && this._StartDateTime != value))
>                {
>                    _StartDateTime = value;
>                }
>            }
>        }
>
>        public System.DateTime EndDateTime
>        {
>            get { return this._EndDateTime; }
>            set
>            {
>                if ((value != null && this._EndDateTime != value))
>                {
>                    _EndDateTime = value;
>                }
>            }
>        }
--------------------------------

I wasn't aware that the timestamp could be parsed into datetime. It's
supposed to be a versioning value, not related to when something
occurred. It's updated with every change to the database.

It is a hex value so try this.
@STAMP = (SELECT CAST(TIMESTAMP_COLUMN) AS DATETIME FROM MyTable)

I wouldn't get a warm fuzzy over this code at all.

Never use a timestamp!    below is from
<http://msdn.microsoft.com/en-us/library/ms182776.aspx>

The Transact-SQL timestamp data type is different from the timestamp
data type defined in the ISO standard.
ms182776.note(en-us,SQL.100).gifNote:
The timestamp syntax is deprecated. This feature will be removed in a
future version of Microsoft SQL Server. Avoid using this feature in
new development work, and plan to modify applications that currently
use this feature.


-- 
Stephen Russell

Sr. Production Systems Programmer
CIMSgts

901.246-0159 cell


-- 
Subscription settings: 
http://groups.google.com/group/dotnetdevelopment/subscribe?hl=en

Reply via email to