Allowing custom attributes to determine Primary Key, Auto Increment, etc. #298
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
These changes allow for attributes(and other logic) from outside of the library to determine whether a column is a Primary Key, Auto Incremented, Indexed, etc.
Reason: I am writing data contracts that I want to be storage agnostic, meaning that I don't want to clutter my data contracts with attributes from many different storage technologies. These could be used by anybody in my company against any data storage technology(json or xml files, SQLite, EntityFramework, etc.). We have this working for the most part for EntityFramework and other storage techs. I am currently implementing storage in our Xamarin application and there are properties I want to ignore from the SQLite database.
For instance, let's say I have an interface and an implementation. Currently, if I wanted to ignore the EmployeeID property, I have to put in ignore attributes like below...
I want to be able to do something like this...
where we can use
MyIgnoreAttribute
to ignore the column in SQLite without having to have a reference to SQLite.This is what I have accomplished with my changes. By providing an instance of
IColumnInformationProvider
, an outside class can determine the information about the column. So for my case, my provider would look like...The changes made to the library are backwards compatible. Setting this property is not required. If an instance is not provided, an instance of the
DefaultColumnInformationProvider
class will be created and used. This default instance does exactly what the code previously did. So not giving a provider will make the library work exactly the same as before.