Search found 20 matches

by niton_dev
Mon 17 Sep 2018 12:08
Forum: EntityDAC
Topic: Run entity setters and validations from a TEntityDataSet
Replies: 2
Views: 5282

Re: Run entity setters and validations from a TEntityDataSet

Could anyone help?
Not a good start considering I'm evaluating this product. I opened a ticket on this subject and until now I got no answer.
by niton_dev
Thu 13 Sep 2018 12:12
Forum: EntityDAC
Topic: Run entity setters and validations from a TEntityDataSet
Replies: 2
Views: 5282

Run entity setters and validations from a TEntityDataSet

I'm evaluating EntityDac.

I would like to know how to make the entity property setter run when a value of an EntityDataSet field is modified.

I would also like to know what strategy to perform validation rules for a given entity before the data is sent to the database when the SaveOnPost property of EntityDataSet is turned on or when SubmitChanges is called in context.

If I modify the values directly in the entity, everything works fine, but when I need to use an EntityDataSet, everything seems to follow a different path.

I need to use the EntityDataSet for controls that do not support LiveBinds, such as devexpress.

Additional info: Im using Attribute-mapped objects
by niton_dev
Tue 28 Nov 2017 11:31
Forum: dotConnect for PostgreSQL
Topic: Mixing data between connections in dotConnect for PostgreSQL, version 7.10.1031
Replies: 4
Views: 2059

Mixing data between connections in dotConnect for PostgreSQL, version 7.10.1031

Problem description:
If I create a DbContext by passing a connection string to a non-existent database and trying to create a second DbContext with a connection string to another non-existent database, the second exception informs that it was not possible to connect the database informed in the first DbContext.

Test scenario:
Visual Studio 2017;
Windows 10;
Console Application .NET Core 2.0;

SQL Script:

Code: Select all

CREATE DATABASE foodb1;

CREATE TABLE foo (
    id integer NOT NULL primary key,
    name text
);
foo clas:

Code: Select all

public partial class foo {

        public foo()
        {
            OnCreated();
        }

        public virtual int id
        {
            get;
            set;
        }

        public virtual string name
        {
            get;
            set;
        }
    
        #region Extensibility Method Definitions

        partial void OnCreated();
        
        #endregion
    }
DbContext Code:

Code: Select all

public partial class FoodbModel : DbContext
    {
        private readonly string _host;
        private readonly int _port;
        private readonly string _database;
        private readonly string _user;
        private readonly string _passWord;

        public FoodbModel(string host, int port, string database, string user, string passWord) :
            base()
        {
            _host = host;
            _port = port;
            _database = database;
            _user = user;
            _passWord = passWord;
            OnCreated();
        }

        //public foodbModel(DbContextOptions<foodbModel> options) :
        //    base(options)
        //{
        //    OnCreated();
        //}

        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            var connectionString = new PgSqlConnectionStringBuilder()
            {
                Host = _host,
                Database = _database,
                Port = _port,
                UserId = _user,
                Password = _passWord,
                LicenseKey = "PUT_YOUR_LICENCE_KEY_HERE"
            }.ConnectionString;

            if (!optionsBuilder.Options.Extensions.OfType<RelationalOptionsExtension>().Any(ext => !string.IsNullOrEmpty(ext.ConnectionString) || ext.Connection != null))
                optionsBuilder.UsePostgreSql(connectionString);
            CustomizeConfiguration(ref optionsBuilder);
            base.OnConfiguring(optionsBuilder);
        }

        partial void CustomizeConfiguration(ref DbContextOptionsBuilder optionsBuilder);

        public virtual DbSet<foo> foo
        {
            get;
            set;
        }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            this.fooMapping(modelBuilder);
            this.CustomizefooMapping(modelBuilder);

            RelationshipsMapping(modelBuilder);
            CustomizeMapping(ref modelBuilder);
        }
    
        #region foo Mapping

        private void fooMapping(ModelBuilder modelBuilder)
        {
            modelBuilder.Entity<foo>().ToTable(@"foo");
            modelBuilder.Entity<foo>().Property<int>(x => x.id).HasColumnName(@"id").HasColumnType(@"int4").IsRequired().ValueGeneratedOnAdd();
            modelBuilder.Entity<foo>().Property<string>(x => x.name).HasColumnName(@"name").HasColumnType(@"text").ValueGeneratedNever();
            modelBuilder.Entity<foo>().HasKey(@"id");
        }
	
        partial void CustomizefooMapping(ModelBuilder modelBuilder);

        #endregion

        private void RelationshipsMapping(ModelBuilder modelBuilder)
        {
        }

        partial void CustomizeMapping(ref ModelBuilder modelBuilder);

        public bool HasChanges()
        {
            return ChangeTracker.Entries().Any(e => e.State == Microsoft.EntityFrameworkCore.EntityState.Added || e.State == Microsoft.EntityFrameworkCore.EntityState.Modified || e.State == Microsoft.EntityFrameworkCore.EntityState.Deleted);
        }

        partial void OnCreated();
    }
Console program code:

Code: Select all

class Program
    {
        static void Main(string[] args)
        {
            try
            {
                //database foodb2 doesn't exists at localhost:5434
                using (var fooMd1 = new FoodbModel("localhost", 5434, "foodb2", "postgres", "put_password_here"))
                {
                    fooMd1.foo.Add(new foo() { id = 1, name = "Test 01" });
                    fooMd1.SaveChanges();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                Console.ReadKey();
            }

            //Try connect in another database

            try
            {
                //database foodb3 doesn't exists at localhost:5434
                using (var fooMd2 = new FoodbModel("localhost", 5434, "foodb3", "postgres", "put_password_here"))
                {
                    fooMd2.foo.Add(new foo() { id = 2, name = "Test 02" });
                    fooMd2.SaveChanges();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                Console.ReadKey();
            }
        }
    }
Program output:
Image

Would you like to know where I'm going wrong?
by niton_dev
Mon 14 Aug 2017 16:59
Forum: dotConnect for PostgreSQL
Topic: Entity Framework Core 2.0 support
Replies: 2
Views: 3458

Entity Framework Core 2.0 support

Is there prediction when the PostgreSQL dotconnect will support Entity Framework Core 2.0?

Final version 2.0 has been released at https://github.com/aspnet/EntityFramewo ... el%2F2.0.0
by niton_dev
Mon 29 May 2017 13:02
Forum: EntityDAC
Topic: Bug with custom mapping rules
Replies: 2
Views: 6139

Re: Bug with custom mapping rules

Someone?
by niton_dev
Fri 26 May 2017 20:16
Forum: EntityDAC
Topic: Bug with custom mapping rules
Replies: 2
Views: 6139

Bug with custom mapping rules

I am using Entity Developer version 9.9.999, which is installed with EntityDAC for Delphi.

I am trying to map an existing PostgreSQL database to a template, but Entity Developer is not using the custom mappings I created.

Apparently custom rule mapping is not working for PostgreSQL. I wonder if it's bug or am I doing something wrong?

Here is a gif of the procedure to reproduce the case.

Tip: Save the gif to disk to see the full width image.

Image
by niton_dev
Thu 25 May 2017 20:39
Forum: EntityDAC
Topic: Error unrecognized configuration parameter "autocommit" when try connect with PostgreSQL 9.5.7 X64 on Windows
Replies: 6
Views: 52602

Re: Error unrecognized configuration parameter "autocommit" when try connect with PostgreSQL 9.5.7 X64 on Windows

Sorry, I realized that I ran the test with an older version of the developer entity that was installed in another directory on my PC. Thank you for your support.
by niton_dev
Sat 20 May 2017 10:16
Forum: EntityDAC
Topic: Error unrecognized configuration parameter "autocommit" when try connect with PostgreSQL 9.5.7 X64 on Windows
Replies: 6
Views: 52602

Error unrecognized configuration parameter "autocommit" when try connect with PostgreSQL 9.5.7 X64 on Windows

Using last version of Entity Developer, I get error "Error unrecognized configuration parameter "autocommit"" when i try connect with PostgreSQL 9.5.7 X64 on Windows.

According with https://www.postgresql.org/docs/9.5/sta ... e-9-5.html, autocommit paramater was removed from PostgreSQL.
by niton_dev
Tue 22 Nov 2016 15:10
Forum: dotConnect for PostgreSQL
Topic: When dotConnect for PostgreSQL will be compatible with EntityFrameworkCore version 1.1.0
Replies: 2
Views: 2965

When dotConnect for PostgreSQL will be compatible with EntityFrameworkCore version 1.1.0

When I try to use dotConnect for PostgreSQL with EntityFrameworkCore version 1.1.0, I get this error in linq query: "argument of AND must be type boolean, not type bit".
by niton_dev
Wed 21 Sep 2016 09:55
Forum: Entity Framework support
Topic: Cannot use Code First from database Wizard in Microsoft.EntityFrameworkCore version 1.0
Replies: 14
Views: 3634

Re: Cannot use Code First from database Wizard in Microsoft.EntityFrameworkCore version 1.0

I found the cause of the error. The error occurs if, in the database, the extension intarray is installed.
by niton_dev
Wed 21 Sep 2016 09:08
Forum: Entity Framework support
Topic: Cannot use Code First from database Wizard in Microsoft.EntityFrameworkCore version 1.0
Replies: 14
Views: 3634

Re: Cannot use Code First from database Wizard in Microsoft.EntityFrameworkCore version 1.0

This is log error in \data\pg_log:

2016-09-21 06:05:55 BRT ERROR: operator is not unique: smallint[] @> smallint[] at character 537
2016-09-21 06:05:55 BRT HINT: Could not choose a best candidate operator. You might need to add explicit type casts.
2016-09-21 06:05:55 BRT STATEMENT:

Code: Select all

	
SELECT

	  a.conname as CONSTRAINT_NAME,

	  ns.nspname as CONSTRAINT_SCHEMA,

	  mycl.relname as TABLE_NAME, 

	  b.conname as REFERENCED_CONSTRAINT_NAME,

	  frns.nspname as REFERENCED_SCHEMA,

	  frcl.relname as REFERENCED_TABLE_NAME,

	  a.confupdtype as UPDATE_RULE,

	  a.confdeltype as DELETE_RULE, 

	  b.contype as REFERENCED_CONSTRAINT_TYPE

	,

	  a.conkey as CONSTRAINT_KEY_INDEXES,

	  a.confkey as REFERENCED_CONSTRAINT_KEY_INDEXES

	FROM 

	  pg_constraint a

	INNER JOIN

	  pg_constraint b ON (a.confrelid = b.conrelid AND a.confkey @> b.conkey AND array_length(a.confkey, 1) = array_length(b.conkey, 1))

	INNER JOIN 

	  pg_namespace ns ON a.connamespace= ns.oid

	INNER JOIN 

	  pg_class mycl ON a.conrelid = mycl.oid

	LEFT OUTER JOIN 

	  pg_class frcl ON a.confrelid = frcl.oid 

	INNER JOIN pg_namespace frns ON frcl.relnamespace= frns.oid

	WHERE a.contype = 'f' 

	  AND (b.contype = 'p' OR b.contype = 'u')

	AND

	  ns.nspname = frns.nspname

	AND

	  ns.nspname = 'public'