Giter Club home page Giter Club logo

Comments (2)

kamranayub avatar kamranayub commented on August 16, 2024

It looks like your DateAdded column allows NULL values. In a full ORM, you could type it as a DateTime? but Massive will just return the pure value, in this case DBNull. Thus, you will probably need some sort of function that converts DBNulls to null and then test for nulls before doing a .ToString() (it would be ideal if Massive took care of DBNull => null conversions for you). Also, it cannot be an extension method because dynamics do not support direct extension methods. I believe Massive will return the date as a DateTime if there's a value in it.

In my own code, I created a mapper class that maps the dynamic onto my POCO class. You could also use AutoMapper, which is what I will probably end up doing. This avoids the issues that may crop up directly dealing with dynamics.

If you want to directly deal with your issue for now, just do:

@if (r.DateAdded != System.DBNull) {
    <td>@r.DateAdded.ToString("dd-MM-yyyy")</td>
} else {
    <td>Unknown</td>
}

from massive.

robconery avatar robconery commented on August 16, 2024

Yep - Massive will only know what type it's using when ADO hands over the value. It looks like this is an "immediate" thing.

Two things come to mind: I need to do some work RE DBNull and ADO really should be returning DataTime?

from massive.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.