Giter Club home page Giter Club logo

Comments (4)

jcachat avatar jcachat commented on June 10, 2024

I have to be honest, I haven't worked with VB for about 20 years. That syntax is not possible in C# and I don't even know how/if that would be handled in the EF MetadataProperties or .Net reflection. I'd be happy to accept a pull request from someone that knows how to solve this. Otherwise, my advice would be to name your properties to match the interface definition.

Btw, the C#/c++ part of me is jealous of that "Implements" option and is also very offended by it. :)

from entityframework.dynamicfilters.

JanusMael avatar JanusMael commented on June 10, 2024

C#

public interface IBlogPost
{
long PrimaryKey { get; set; }
}

public class BlogPost : IBlogPost
{
//this is what VB does under the hood with 'implements' as described in the example above
public long ID
{
get { return ((IBlogPost)this).PrimaryKey; }
set { ((IBlogPost)this).PrimaryKey = value; }
}
long IBlogPost.PrimaryKey { get;set;}
}

from entityframework.dynamicfilters.

jcachat avatar jcachat commented on June 10, 2024

Thanks Januschan, that's helpful. Defining a C# class/interface like that, I am able to reproduce the problem.

But, I'm not able to solve it. The problem is that according to the EF model that is produced by that class, the public property name is "ID", not "PrimaryKey". So what happens is that I see there is a filter on BlogEntry on the PrimaryKey property. But then none of the properties in the EF entity have that column so we fail to create the filter (and an exception will be thrown). There is no way to know that there is code there which is mapping "ID" to "PrimaryKey" in this particular class.

I'm sorry, but I don't see that there is any way this can be supported. If you want to create a filter against the interface, you will not be able to re-map your properties like this. Or you will need to create your filter on the entity itself, not the interface.

from entityframework.dynamicfilters.

JanusMael avatar JanusMael commented on June 10, 2024

I think it makes sense not to support this VB compiler trick. I was just
illustrating what that compiler does, and this info allows VB developers to
explicitly implement the underlying code for it. C# also has some compiler
trick candy which is not strictly supported by <your .NET lib here>.

~B
On Jan 4, 2015 6:47 PM, "jcachat" [email protected] wrote:

Thanks Januschan, that's helpful. Defining a C# class/interface like that,
I am able to reproduce the problem.

But, I'm not able to solve it. The problem is that according to the EF
model that is produced by that class, the public property name is "ID", not
"PrimaryKey". So what happens is that I see there is a filter on BlogEntry
on the PrimaryKey property. But then none of the properties in the EF
entity have that column so we fail to create the filter (and an exception
will be thrown). There is no way to know that there is code there which is
mapping "ID" to "PrimaryKey" in this particular class.

I'm sorry, but I don't see that there is any way this can be supported. If
you want to create a filter against the interface, you will not be able to
re-map your properties like this. Or you will need to create your filter on
the entity itself, not the interface.


Reply to this email directly or view it on GitHub
#8 (comment)
.

from entityframework.dynamicfilters.

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.