Closed paule96 closed 6 months ago
Hello, @paule96! So that the author can quickly understand what exactly is not working, could you provide the code of your case? How you add data and how you try to read it. What do you have there in "postgreGraphDemo.Api Service.Program.cs"?
Oh right I forgot to mention that. I used the sample of the Readme from that repo ✌️
Basically the following lines are the issue:
// Read the result row by row.
while(await reader.ReadAsync())
{
var agtypeResult = reader.GetValue(0);
Vertex person = agtypeResult.GetVertex();
// Do something with vertex.
}
I have this example, on Apache AGE installed in Postgres according to this instruction, it also gives the same error. Apparently, the problem is Npgsql, which does not support "agtype". I don't know how to fix it yet, but this problem is most likely related to this issues: "Is there any plan to support Apache AGE extension? #4514".
In theory, Npgsql can somehow be extended to support additional data types. Here, for example, a similar thing was done.
Yes, @glazkovalex. The issue is that Npgsql doesn't automatically map to AGE's 'agtype'. I will work on creating a mapping.
Yes, @glazkovalex. The issue is that Npgsql doesn't automatically map to AGE's 'agtype'. I will work on creating a mapping.
I'm one of the maintainers of Npgsql, if you need help with this let me know.
Hello, @NinoFloris!
Yes, @glazkovalex. The issue is that Npgsql doesn't automatically map to AGE's 'agtype'. I will work on creating a mapping.
I'm one of the maintainers of Npgsql, if you need help with this let me know.
You probably need to clarify the context of the problem. The Apache Age extension usually returns objects of its own type agtype
as a result of the request, the data structure of which is described in detail here.
Here is an example of what returns a request from the discussed Quickstart directly to pgAdmin:
See, this is a special type of agtype
and not a string or json because of ":vertex".
@Allison-E described the 'agtype' data types in C#, but Npsgql does not know how to convert 'agtype' to the data types described by @Allison-E. An exception occurs: System.InvalidCastException: "Reading as 'System.Object' is not supported for fields having DataTypeName 'ag_catalog.agtype'"
In your issue 4514 on https://github.com/npgsql/npgsql/issues/4514#issuecomment-1167617467 @roji wrote about this issue:
@FrancescoSillani that's good - it means that the AGE extension does support binary I/O for the
agtype
type, and can therefore be supported in Npgsql. But someone would still need to write the Npsgql type handlers which encode/decode the binary representation etc.
Have you ever come across information or an example of how you can write these handlers for unsupported in Npgsql agtype
types which encode/decode the binary representation?
This has now been fixed in ApacheAGE v1.0.0. The System.InvalidCastException
being thrown was resolved by creating a custom converter and resolver to add in-built support for the ag_catalog.agtype
PostgreSQL type in Npgsql.
hi,
I currently try to play around with pg-age and dotnet. So I found this library. Because playing around with docker is easy, I use the official docker image
apache/age
. This has a preconfigured postgre with the age extension installed.I started to try the extension and couldn't read the data:
it seams like the the
getValue
methods try to read things as objects but are not able todo so.