question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Abstract Property / Polymorphismus

See original GitHub issue

Hello,

I have an abstract Property in my Row-Projection e. g.

abstract class AbstractArticleData 
{
  public int ArticleId {get;set;}
}

class Article {
  public int ArticleId {get;set;}
  public AbstractArticleData SpecialData {get;set;}
}

class ArticleData : AbstractArticleData {
 // Other Properties
}

There is a “double” projection, first I project ArticleRow to Article, then I Project new { Article, ArticleData } to Article again.

At this moment I can’t provide a testcase, but I think Linq2DB can’t handle abstract Data types in genereal, because he wants to instantiate AbstractArticleData which results in a System.Linq Exception.

Any Ideas how I can extend Linq2DB to instantiate the correct data type (ArticleData)?

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:17 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
sdanylivcommented, Jan 23, 2019

@Fruchuxs, sorry not yet. Will handle this next week, currently i’m too busy with main work.

1reaction
sdanylivcommented, Dec 18, 2018

@Fruchuxs, i see looks like you don’t need inheriatance mapping, but just want to easy switch between options which ancestor needs to be intstantiated. There is no option for now, but can be emulated by inheritance mapping.

Inheriatnce mapping is trying to instantiate different classes from the same table based on value of Discriminator Column.

Will try to find solution for you later.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Understanding Polymorphism using Abstract Classes in C# ...
With polymorphism, you can define a single abstract class and reshape it in different ways to suit your methods & ideas.
Read more >
Polymorphism Using Abstract Classes and Interfaces
In this article, you'll learn how to share and enforce code with polymorphism using abstract classes and interfaces.
Read more >
Inheritance, Polymorphism, and Abstract Classes
An abstract class exists only to express the common properties of all its subclasses. A class that is not abstract is said to...
Read more >
JAXB Inheritance: Polymorphism and Abstract Classes
An abstract class is a class that cannot be instantiated, but can be used as a superclass for other classes. It can have...
Read more >
Object-Oriented Programming in Python: data abstraction ...
abstractmethod() may be used to declare abstract methods for properties and descriptors. Polymorphism is an important feature of class definition in Python ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found