unknown System.InvalidCastException.

Discussion of open issues, suggestions and bugs regarding LinqConnect – Devart's LINQ to SQL compatible ORM
Post Reply
MisterStinky
Posts: 5
Joined: Thu 15 Jan 2009 22:51

unknown System.InvalidCastException.

Post by MisterStinky » Mon 23 Feb 2009 17:33

Hi - I am wondering if anyone has seen this exception:

System.InvalidCastException: Null object cannot be converted to a value type.
at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider)
at Devart.Data.Linq.Provider.DataProvider.a(String A_0, IList`1 A_1, IDbCommand& A_2)
at Devart.Data.Linq.r.a(MetaType A_0, n A_1, Object A_2, ModifiedMemberInfo[] A_3)
at Devart.Data.Linq.t.a(h A_0, Object A_1, ModifiedMemberInfo[] A_2)
at Devart.Data.Linq.i.a(e A_0)
at Devart.Data.Linq.i.d()
at Devart.Data.Linq.DataContext.SubmitChanges()

I've been beating my head against the desk for a day now. It gets thrown even though I am passing in values for everything in the DB. And other tables int the same database are able to update fine.

I'm using the most recent version of dotConnect and Entity Developer


Here is the general structure of my code.

The table I am trying to update:
CREATE TABLE table_catalog
(
id integer NOT NULL DEFAULT nextval('table_catalog_id_seq'::regclass),
common_name character varying(25) NOT NULL,
description character varying(256),
string_type_one character varying(512),
string_type_two character varying(64),
token timestamp without time zone NOT NULL DEFAULT timezone('UTC'::text, now()),
CONSTRAINT table_catalog_pkey PRIMARY KEY (id),
CONSTRAINT table_common_name_key UNIQUE (common_name)
)
And looking at the dbml i see this:











And the values that I am passing in are:
p1.Name: ID setting to value: 1 from value: 1
p1.Name: CommonName setting to value: "MyCommonName" from value: "MyCommonName"
p1.Name: Description setting to value: "This is a test description." from value: "This is a test description. - Blah"
p1.Name: StringTypeOne setting to value: "" from value: null
p1.Name: StringTypeTwo setting to value: "" from value: null

I can't for the life of me figure out why I am getting the Null object exception. Any help would be most appreciated. Thank you

AndreyR
Devart Team
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Post by AndreyR » Tue 24 Feb 2009 12:19

Do you have the latest build of dotConnect for PostgreSQL? I have just tried to update the table_catalog and succeeded.
I used the following code:

Code: Select all

      using (DataContext1.DataContext1 db = new DataContext1.DataContext1()) {
        table_catalog tc = db.table_catalogs.First();
        tc.description = "test3";
        tc.string_type_one = "";
        tc.string_type_two = "";
        db.SubmitChanges();
      }
Could you please post the code you used for update?

MisterStinky
Posts: 5
Joined: Thu 15 Jan 2009 22:51

Post by MisterStinky » Tue 24 Feb 2009 16:49

I believe that I do.
Devart.Data.DLL is version: 5.0.1.0
Devart.Data.Linq.DLL is version: 1.0.6.0
Devart.Data.PostgreSql.DLL is version: 4.0.22.0
Devart.Data.PostgreSql.Linq.DLL is version: 1.0.6.0

is there an email that I could use to send you the other information?

AndreyR
Devart Team
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Post by AndreyR » Wed 25 Feb 2009 11:16

Please send me a little test project illustrating the error (support * devart * com, subject "LINQ and InvalidCastException").

Post Reply