Skip to content
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

One To Many References not working #682

Open
deekoulos opened this issue Mar 11, 2023 · 1 comment
Open

One To Many References not working #682

deekoulos opened this issue Mar 11, 2023 · 1 comment

Comments

@deekoulos
Copy link

deekoulos commented Mar 11, 2023

Hi there,
i googled a lot including chatgpt, none of it is working for me.
I am trying to do a very simple one to many relation between 2 tables, and get the sequence contains no elements exception.

[TableName("ServiceProviders")]
[PrimaryKey("Id")]
[ExplicitColumns]
public class ServiceProvider
{
        [Column("ServiceProviderId")]
        public int Id { get; set; }

        [Reference(ReferenceType.Many, ColumnName = "ServiceProviderId", ReferenceMemberName = "MemberId")]
        public List<Test> Tests { get; set; }
}

[TableName("Tests")]
[PrimaryKey("Id", AutoIncrement = true)]
[ExplicitColumns]
public class Test
{
    [Column("TestId")]
    public int Id { get; }

    [Column("MemberId")]
    public int MemberId { get; set; }

    [Reference(ReferenceType.Foreign, ColumnName = "ServiceProviderId", ReferenceMemberName = "Id")]
    public ServiceProvider ServiceProvider { get; set; }
}

I also tried the following without success:

    [TableName("ServiceProviders")]
    [PrimaryKey("Id")]
    [ExplicitColumns]
    public class ServiceProvider
    {
        [Column("ServiceProviderId")]
        public int Id { get; set; }

        [Reference(ReferenceType.Many, ColumnName = "ServiceProviderId", ReferenceMemberName = "ServiceProvider")]
        public List<Test> Tests { get; set; }
    }
    [TableName("Tests")]
    [PrimaryKey("Id", AutoIncrement = true)]
    [ExplicitColumns]
    public class Test
    {
        [Column("TestId")]
        public int Id { get; }

        [Column("MemberId")]
        public int MemberId { get; set; }

        [Reference(ReferenceType.Foreign, ColumnName = "ServiceProviderId", ReferenceMemberName = "Id")]
        public ServiceProvider ServiceProvider { get; set; }
    }

what am i missing?

Best,
Dee

@deekoulos
Copy link
Author

I also copy pasted the fixed example provided here: #315

still getting the sequence contains no elements error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant