GithubHelp home page GithubHelp logo

Comments (4)

schotime avatar schotime commented on August 20, 2024

Hey Chris,

Thanks for the bug report.
Could you provide me with some more information (or some code) that describes the exact problem so that I can create a test for it.

Cheers,
Adam

from npoco.

79it avatar 79it commented on August 20, 2024

After bit more research, it appears to affect only members with Nullable type.

I'm using MySQL as the database and columns causing this issue are defined in the database as INT(10) UNSIGNED NOT NULL.

Types interpreted as DECIMAL, FLOAT, DOUBLE, INT and STRING do not seem to cause a problem.

When such a field is used on the left side of a left join it could null so Entity Framework will set up this field as Nullable rather than just long.

Because the property is defined as nullable, when dstType is passed to Convert.ChangeType it is reading Nullable rather than the underlying data type and any non-null value causes a problem.

My SafeConvert method gets the underlying data type and uses that if the value is not null or returns null if the value is null.

I set up a simple test like this (obviously an ID column would not usually be null - in this case remember it was defined like this because it was on the left side of the join). I have included decimal and int types to show these do not cause the problem:

POCO:

public class test
{
    public Nullable<long> ItemID { get; set; }
    public string Code { get; set; }
    public string ItemName { get; set; }
    public Nullable<decimal> Price { get; set; }
    public Nullable<int> Stock { get; set; }
}

Request:

List<test> myModel = db.Fetch<test>("select * from content");

If you change public Nullable ItemID { get; set; } to public long ItemID { get; set; } you won't get the problem.

Please let me know if you need more info.

Thanks

Chris

from npoco.

schotime avatar schotime commented on August 20, 2024

Hi Chris,

I have managed to reproduce this and fix it with your suggestions.
Please checkout 2.1.23-beta on NuGet to see if it now works.

Cheers,
Adam

from npoco.

79it avatar 79it commented on August 20, 2024

I just downloaded the latest branch and so far so good.

Thanks for the speedy fix.

Chris

from npoco.

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.