Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement inference for NpgsqlParameter.DataTypeName from NpgsqlDbType/DbType/ClrType #2520

Open
ebonat opened this issue Jul 9, 2019 · 7 comments

Comments

@ebonat
Copy link

commented Jul 9, 2019

Write a simple line of code in a C# console project as:

using Npgsql;
using NpgsqlTypes;

var field1 = new NpgsqlParameter("par_field1", NpgsqlDbType.Varchar, 50);

and i got the following error:

'field1 .DataTypeName' threw an exception of type 'System.NotImplementedException'

i'm using now:

Npgsql 4.0.7.0
EntityFramework6.Npgsq 3.2.1.1
PostgreSQL 11.4
Windows 7

Thanks for your help!

-Ernest

@roji

This comment has been minimized.

Copy link
Member

commented Jul 9, 2019

This doesn't happen for me. It's true that if you try to read NpgsqlParameter.DataTypeName without having written to it, you will get a NotImplementedException - but not simply by instantiating the parameter. Can you please retest?

@ebonat

This comment has been minimized.

Copy link
Author

commented Jul 9, 2019

OK, doing it now...

@ebonat

This comment has been minimized.

Copy link
Author

commented Jul 9, 2019

in general the error does not occurred, but set the break point on the variable field1, move to next like and look at the DataTypeName property of it. why it shows this 'System.NotImplementedException' on it? explain?

thank you!

-Ernest

@roji

This comment has been minimized.

Copy link
Member

commented Jul 10, 2019

If you use the debugger to look at a property, its getter is called. And as I wrote above, NpgsqlParameter.DataTypeName currently works only if you write to it first, otherwise it throws NotImplementedException. You can simply ignore this exception while debugging.

@ebonat

This comment has been minimized.

Copy link
Author

commented Jul 10, 2019

why the property NpgsqlParameter.DataTypeName is throwing a NotImplementedException if i'm not using it?

i don't want to see any exception in my application at all!

@roji

This comment has been minimized.

Copy link
Member

commented Jul 11, 2019

The exception is only being triggered because you use the debugger to access the property. If you don't access the property, you won't get the exception.

@roji roji added this to the Backlog milestone Jul 11, 2019

@roji roji changed the title DataTypeName' threw an exception of type 'System.NotImplementedException' Implement inference for NpgsqlParameter.DataTypeName from NpgsqlDbType/DbType/ClrType Jul 11, 2019

@ebonat

This comment has been minimized.

Copy link
Author

commented Jul 11, 2019

roji, thank you for all your help!

-ernest

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.