Sql Query Based On DateTime in .Net

classic Classic list List threaded Threaded
2 messages Options
siva siva
Reply | Threaded
Open this post in threaded view
|

Sql Query Based On DateTime in .Net

This post was updated on .
Hi

I am running .net core app as a server and using .net thin-client for crud
operations and SQL query . Here is the problem i am facing.

Model Class

{
    public class Employee
    {
        [QuerySqlField]
        public int Id { get; set; }
        [QuerySqlField]
        public string Name { get; set; }
        private DateTime _JoinDate;
        [QuerySqlField]
        public DateTime JoinDate
        {
            get
            {
                return _JoinDate;
            }
            set
            {

                _JoinDate=  DateTime.SpecifyKind(value,DateTimeKind.Utc);
            }
        }
    }
}


Here Getter and Setter using for to Convert DateTime to Utc DateTime .

If I  Use
Cache.Get("1")  able to get the JoinDate (i.e. DateTime Field) in Object
Which I have store in Cache
 But if I Use Sql Query Not able to get value.I have Looked at SqlLine
,JoinDate Field Comming as Empty in Result

Using cache.Get() result
<http://apache-ignite-users.70518.x6.nabble.com/file/t1379/picturemessage_apmhker5.png


Using sql Query Result

<http://apache-ignite-users.70518.x6.nabble.com/file/t1379/picturemessage_btry3pys.png


In SQl Line Query Result

<http://apache-ignite-users.70518.x6.nabble.com/file/t1379/picturemessage_0dud44xi.png



Thanks





















--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
Alexandr Shapkin Alexandr Shapkin
Reply | Threaded
Open this post in threaded view
|

Re: Sql Query Based On DateTime in .Net

Hi,

I would suggest you to move your business logic out of queryable fields.
Put [QuerySqlField] to plain _JoinDate and rewrite your sql to "where
_JoinDate = ..."

This should work as your *cache.Get() result* example.



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
Alex Shapkin