Search code examples
c#mysqlmysql-x-devapi

Filter using date field in mysql Document store(Nosql) in C#


How can i filter a date field in document store table (NoSQL) in c#. i need to filter created ate greater than particular time.

the date is storing as string values in nosql.

I had only found the below mentioned code to filter in C# mysql-x-devspi.

var myDb = mySession.GetSchema(Myschema);
var myColl = myDb.CreateCollection("Mytbl",true);
var docs = myColl.Find("createdtime > :starttime")
.Bind("starttime", DateTime.UtcNow)
.Execute();

Solution

  • You need a date value from somewhere and which you want to filter aso

    MySQL needs "his" date format, automatic doesn't work always.

     DateTime dateValue= DateTime.Now;
     ....
    .Bind("starttime", dateValue.ToString("yyyy-MM-dd HH:mm:ss")) 
    

    But as stated in my comment a RDMS like MySQL and a NoSQL are mainly different, and mysql is definitely no NoSQL.

    You can take a look https://www.sitepoint.com/sql-vs-nosql-differences/ where the main differences are explaind