Page 1 of 1

not able to reference PgSqlJsonbFunctions

Posted: Tue 25 Sep 2018 00:47
by gajus
Hi,

I am trying to get some JSONB functionality working and have been banging my head against the wall way too long now. Hope any of you guys can shed some light here.

So just following all the instructions here (pretty much used the code exactly as provided)

https://www.devart.com/dotconnect/postg ... pport.html

using:

dotConnect: 7.11.1229.0
Devart.Data: 5.0.2021.0
Devart.Data.Postgresql 7.11.1229.0
Devart.Data.Postgresql.Entity.EF6 7.6.763.0

Here's my code:

Code: Select all

using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Devart.Data.PostgreSql;

namespace ConsoleApp1
{

    public class MyContext : DbContext
    {

        public DbSet<JsonTable> JsonTables { get; set; }

    }

    public class JsonTable
    {

        [Key]
        [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        public int Id { get; set; }

        [Column(TypeName = "jsonb")]
        public string JObject { get; set; }

        public string Text { get; set; }

    }

    class Program
    {
        static void Main(string[] args)
        {
            var context = new MyContext();
            context.Database.Create();


            var query = context.JsonTables
              .Where(t => PgSqlJsonbFunctions.GetObjectFieldAsText(t.JObject, "a") == "foo")
              .Select(t => new {
                  Id = t.Id,
                  Json = t.JObject,
                  ObjectType = PgSqlJsonbFunctions.TypeOf(t.JObject),
                  FieldType = PgSqlJsonbFunctions.TypeOf(PgSqlJsonbFunctions.ExtractPath(t.JObject, "a")),
                  ExtractPath = PgSqlJsonbFunctions.ExtractPath(t.JObject, "a"),
                  ExtractPathText = PgSqlJsonbFunctions.ExtractPathText(t.JObject, "a"),
                  GetObjectField = PgSqlJsonbFunctions.GetObjectField(t.JObject, "a"),
                  GetObjectFieldAsText = PgSqlJsonbFunctions.GetObjectFieldAsText(t.JObject, "a")
              });
        }
    }
}

The problem is that PgSqlJsonbFunctions is not reference from any assembly.

hope someone can shed some light on the problem at hand.

Kind regards Gajus

Re: not able to reference PgSqlJsonbFunctions

Posted: Fri 28 Sep 2018 18:19
by Shalex
The PgSqlJsonFunctions and PgSqlJsonbFunctions classes are implemented in EF4/EF5/EF6 to use JSON/JSONB functions and operators in LINQ to Entities queries starting from the 7.7.794 version.
gajus wrote:
Tue 25 Sep 2018 00:47
dotConnect: 7.11.1229.0
Devart.Data: 5.0.2021.0
Devart.Data.Postgresql 7.11.1229.0
Devart.Data.Postgresql.Entity.EF6 7.6.763.0
Please remove reference to Devart.Data.Postgresql.Entity.EF6 7.6.763.0 and add reference to Devart.Data.Postgresql.Entity.EF6 7.11.1229.0. Now PgSqlJsonbFunctions should be available in the Devart.Data.PostgreSql.Entity namespace.

Does this help?

Re: not able to reference PgSqlJsonbFunctions

Posted: Wed 03 Oct 2018 09:51
by gajus
thanks shalex,

works like a charm:)