Comments (11)
Anyone interested in this?
from dapper.simplecrud.
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.
@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.
@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.
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.
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.
Yes you can. There is a working example of this in the unit tests project.
from dapper.simplecrud.
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.
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.
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.
Its no problem. :)
from dapper.simplecrud.
Related Issues (20)
- SimpleCrud works using oracle driver but not odbc
- Insert with Guid as Key: Inconsistent behaviour async/sync
- When inserting entity with int? Id assigned a value other than null, the assigned value is returned instead of the inserted entity's Id HOT 1
- Add fluent config in separate class
- Type Handler not being called for SimpleCRUD extensions HOT 2
- Support mordern sqlserver page query like OFFSET ROWS FETCH NEXT
- Does the library only support SQL Server and not Oracle?
- Attribute for selective inclusion of columns in insert/update HOT 1
- How to insert in CLOB columns with SimpleCRUD ?
- _getIdentitySql for postgres misaligns with actual id of inserted entity
- Tons of exceptions thrown in trying to generate CRUD, PostgreSQL DB
- Using Guids without Guid type in the database (MariaDB)
- GetListPagedAsync fails on table with HierarchyID field type
- System.IndexOutOfRangeException Index was outside the bounds of the array.
- Complex fields not included in SELECT/UPDATE queries
- Question: A primary key that is not identity. HOT 1
- Add support for DateOnly and TimeOnly
- Ignore Update if property value is null
- Support for composite keys ? HOT 1
- it is a bug about string whereCondition HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dapper.simplecrud.