Giter Club home page Giter Club logo

Comments (3)

slipjig avatar slipjig commented on July 20, 2024 1

In my example above, if I change it to use .RegisterEntity() instead of .GetDefaultEntityMapping(), it runs.

from fastcrud.

slipjig avatar slipjig commented on July 20, 2024

I am getting this error as well, using fluent registration. Here is a simple example to duplicate the issue:

public class Parent {
    public long Key { get; set; }
    public IEnumerable<Child> Children { get; set; }
}

public class Child {
    public long Key { get; set; }
    public long ParentKey { get; set; }
    public Parent Parent { get; set; }
}

public class Config {
    private static void ConfigureParentsAndChildren() {
        OrmConfiguration.GetDefaultEntityMapping<Parent>()
            .SetDialect(SqlDialect.MySql)
            .SetTableName("parents")

            .SetProperty(p => p.Key, p => p
                .SetDatabaseColumnName("parent_id")
                .SetPrimaryKey()
                .SetDatabaseGenerated(DatabaseGeneratedOption.Identity))

            .SetParentChildrenRelationship(                         //<-------- FAILS
                p => p.Children,
                c => c.Parent
            );

        OrmConfiguration.GetDefaultEntityMapping<Child>()
            .SetDialect(SqlDialect.MySql)
            .SetTableName("children")

            .SetProperty(p => p.Key, p => p
                .SetDatabaseColumnName("child_id")
                .SetPrimaryKey()
                .SetDatabaseGenerated(DatabaseGeneratedOption.Identity))

            .SetChildParentRelationship(
                c => c.Parent,
                c => c.ParentKey
            );
    }
}

Is this supposed to work the way I've written it?

from fastcrud.

MoonStorm avatar MoonStorm commented on July 20, 2024

In my example above, if I change it to use .RegisterEntity() instead of .GetDefaultEntityMapping(), it runs.

RegisterEntity should be the right way when performing fluent registrations from scratch, as GetDefaultEntityMapping will make inferations that need to be overridden. Let me know if you do encounter any more problems in this area.

from fastcrud.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.