Hi,

Please properly subscribe to the mailing list so that the community can
receive email notifications for your messages. To subscribe, send empty
email to [email protected] and follow simple instructions in
the reply.

I have reproduced the problem, it is caused by the fact that DateTime is
serialized in .NET-specific format by default, and this does not work in
SQL, see "DateTime and SQL" section:
https://apacheignite-net.readme.io/docs/sql-queries#section-java-type-name-mapping

To enforce SQL-compatible TimeStamp format:
1) Mark the field with [QuerySqlField]. Looks like this is not an option for
you, though, since reflection is used

2) Implement IBinarizable:

public class ABC : IBinarizable
{
        public int Id { get; set; }
        public string Name { get; set; }
        public DateTime StartTime { get; set; }

        public void WriteBinary(IBinaryWriter writer)
        {
                writer.WriteInt("Id", Id);
                writer.WriteString("Name", Name);
                writer.WriteTimestamp("StartTime", StartTime);
        }

        public void ReadBinary(IBinaryReader reader)
        {
                Id = reader.ReadInt("Id");
                Name = reader.ReadString("Name");
                StartTime = 
reader.ReadTimestamp("StartTime").GetValueOrDefault();
        }
}

3) Implement IBinarySerializer:

public class AbcSerializer : IBinarySerializer
{
        public void WriteBinary(object o, IBinaryWriter writer)
        {
                var abc = (ABC)o;
                
                writer.WriteInt("Id", abc.Id);
                writer.WriteString("Name", abc.Name);
                writer.WriteTimestamp("StartTime", abc.StartTime);
        }

        public void ReadBinary(object o, IBinaryReader reader)
        {
                var abc = (ABC)o;
                
                abc.Id = reader.ReadInt("Id");
                abc.Name = reader.ReadString("Name");
                abc.StartTime = 
reader.ReadTimestamp("StartTime").GetValueOrDefault();
        }
}

and register it in config:
                BinaryConfiguration = new BinaryConfiguration
                {
                        TypeConfigurations = new[] { new 
BinaryTypeConfiguration(typeof(ABC)) {
Serializer = new AbcSerializer() }}
                }




--
View this message in context: 
http://apache-ignite-users.70518.x6.nabble.com/Dymanically-add-QueryField-on-Cache-Entity-and-perform-DateTime-filter-tp14318p14319.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Reply via email to