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

  • Home
  • SEARCH
  • 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 8069017
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T12:52:35+00:00 2026-06-05T12:52:35+00:00

I am decorating one of my DateTime property in my class with Representation =

  • 0

I am decorating one of my DateTime property in my class with Representation = BsonType.Int64 attribute so that it gets stored in the database with Int64 representation of a date.

When I used to store that property as a normal C# Datetime and did not set the value to anything then it would store DateTime.Min in the database. That is perfect because I was doing reading from databse and doing Query.LT operation like following on it:

Query.LT("MyField", DateTime.Now));

And it used to return all the values fine.

Now that I started storing it as BsonType.Int64 and the equivalent of DateTime.Min in BsonType.Int64 is “0”. my Query.LT(“MyField”, DateTime.Now)); fails on all the dates that are stored with DateTime.Min.

Any idea on how to solve this?

  • 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-06-05T12:52:39+00:00Added an answer on June 5, 2026 at 12:52 pm

    The problem is that, during the query, the MongoDB driver doesn’t know that you chose an alternate representation.

    Hence, you need to query for an Int64 explicitly:

    Query.LT("MyField", DateTime.Now.Ticks));
    

    This will work as expected (tested w/ MongoDB 2.1.1, C# driver 1.4.2.4500)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I current have the following attribute decorating one of the action method. [Authorize(Roles =
I have one view that used to display the result of my search item.
What is a simple example of decorating a class by defining the decorator as
This is a strange one that I cannot see to figure out. I have
I want to to have content like below for this first one I used
I have created a list of images on one of my web pages that
I have a regular C# POCO. At the class level, I am decorating the
I'm trying to create custom drop-down select like the one used on twitter when
I am designing a web application that retrieves records from a database according to
I have a table, with one column <table> <tr> <td width=30 class=top-nav><a href=#>Home</a></td> <td

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.