-
Notifications
You must be signed in to change notification settings - Fork 600
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
Unable to Insert/Update Record using Expando Object in VB.NET #719
Comments
Can you use an anonymous type in your code? That avoids having to create a concrete class, and it's probably no more code than populating an expando. |
Do you have an idea on how to declare anonymous types in vb.net and how to use it on PetaPoco? |
There's an example of inserting with an expando here: https://github.com/CollaboratingPlatypus/PetaPoco/wiki/Support-for-dynamic |
@iadaz Inserts with dynamics appears to be broken at the moment. There is a pending PR which I think addresses this. @rizalmart In C# the code would look something like this: var newRecord = new {
field1 = "foo",
field2 = "bar"
};
db.Insert("my_table", newRecord); I don't work in VB, but here are the relevant docs on anonymous types. |
I follow this method here from petapoco `// Create a new record // Insert it // New record ID returned with a new property matching the primary key name But it only threw error message that it does not allow expando object on insert |
Yes, as I said, I think there's currently a bug. The code I gave above is for using anonymous types instead of Expandos. You can see that it's not much work, about the same as Expandos. |
Hi, I was facing a similar problem, but in C#, understand there is a bug but just wondering if there is a workaround. So I was populating a
the column names of the table are in the
but this throws an Exception
Can I use the looping technique on an anonymous object? or is there any other way I get the data into the database from the 2 lists. |
PetaPoco threw error message when inserting/updating records using expando object. It requires to manually create a class that represents the the row in order to insert it. This was hassle for developers to create a class which represents a row before inserting/updating records because it adds more time and lines of code
The text was updated successfully, but these errors were encountered: