Giter Club home page Giter Club logo

Comments (11)

ericdc1 avatar ericdc1 commented on May 18, 2024

Anyone interested in this?

from dapper.simplecrud.

chrishylton avatar chrishylton commented on May 18, 2024

I personally would definitely welcome this, similar to the table name attribute. Would be very helpful in legacy databases that have cryptic column names from being built in yesteryear and can't be altered. It would eliminate wrapping tables in views or hardcoded SQL in the data layer.

from dapper.simplecrud.

mxmissile avatar mxmissile commented on May 18, 2024

@chrishylton that's exactly why I submitted the feature request, glad I'm not the only one working in a brownfield app :-)

from dapper.simplecrud.

chrishylton avatar chrishylton commented on May 18, 2024

@mxmissile :-) yep, I frequently live in poo covered databases that have to be used in newer apps. Dapper and SimpleCRUD are lifesavers but I frequently get pushed back into Dapper proper due to this type of issue, or having to live with cryptic property names on my objects. The DBA in me says remove all security access to tables and push data through stored procedures or views with appropriate aliased column names. The developer in me has embraced Dapper and SimpleCRUD as my be-all-end-all data layer and screw the DBA in me.

from dapper.simplecrud.

ericdc1 avatar ericdc1 commented on May 18, 2024

I added this. It was a bit harder than expected as it effected quite a bit. Get and GetList needed the select to specify column names rather than select *. When a column attribute is used it has to alias the column to the model name so model mapping happens. The where clause was a fun challenge too. You can use the anonymous object for the where clause based on the name in the model and SimpleCrud will figure out the database column name to query. Its on Nuget as a prerelease package until I can test it some more. Please let me know what you think. https://www.nuget.org/packages/Dapper.SimpleCRUD/1.7.0-prerelease

from dapper.simplecrud.

chrishylton avatar chrishylton commented on May 18, 2024

eric, question on this. haven't had a chance to look into the code, so I suspect the answer is 'no', but can you somehow use the [Key] and [Column] attributes together. Looking to alias my db 'Id' column as something else in order to handle object/table inheritance and it doesn't seem to like the [Column] attribute if the [Key] attribute is there also. Thanks. Chris.

btw, even w/ this issue (which i'm working around w/ a shallow copy of my object using reflection), this new [Column] capability is great. Thanks again for doing it ! ! !

from dapper.simplecrud.

ericdc1 avatar ericdc1 commented on May 18, 2024

Yes you can. There is a working example of this in the unit tests project.

from dapper.simplecrud.

chrishylton avatar chrishylton commented on May 18, 2024

thanks eric, just now getting back to this. I'm either missing the unit test or looking in the wrong place. Looked in Dapper.SimpleCRUDTests (Tests.cs), but not seeing a combo of [Key] and [Column]. Tried it in my own code back before I posted the above question, and my Get< T > still errored out with the single key message. Don't have the example in front of me, but I can mock up an example of what I tried if you need it. No rush, I moved to a model of not even using an Id named column, my Key is Base._Id or Derived._DerivedId and mapped each w/ [Key] and this addressed my needs with my base/derived classes.

from dapper.simplecrud.

ericdc1 avatar ericdc1 commented on May 18, 2024

Here is the model http://screencast.com/t/MoLwLxEw
And here are a few of the tests http://screencast.com/t/LTwLL2jyQ6MC

Is there something you need beyond that?

from dapper.simplecrud.

chrishylton avatar chrishylton commented on May 18, 2024

um...nope...that'll do it. I promise, I pulled up Tests.cs today and searched for [Key and didn't run into what you have in your screencast. But obviously its there and its been there, found it tonight. I must be loosing it. Sorry. I must have had something else jacked up in my code, I'll try this again. Had both of those attributes on my class just like you have them in that test. Sorry for the run-around, I'll shut my pie-hole now.

from dapper.simplecrud.

ericdc1 avatar ericdc1 commented on May 18, 2024

Its no problem. :)

from dapper.simplecrud.

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.