Giter Club home page Giter Club logo

dbautofill's People

Contributors

jsvircom avatar mrtryhard avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Forkers

mrtryhard

dbautofill's Issues

Properly document the library and the readme.

Right now the documentation is really minimal (close to non-existent) and unclear.
The objective if to create a clearer and simpler documentation. If time permits, adding some peculiar case would be good, too.

  • Readme
    • Features
    • Sample
  • Wiki
    • Introduction (sample program)
    • Helpers doc
    • Basic types docs
    • Adding features doc

Bug: DbAutoFill crashes when using plain fields

While testing for issue #3 Proposal, I discovered a little bug where plain field members do raise an exception in the AddParameterFromAttribute (L.302 of DbAutoFillHelper.cs).

Issue comes from the assertion that we're awaiting a property (model.GetType().GetProperty(propertyName).GetValu(model, null)).

The solution is to test like the following;

Type modelType = model.GetType(); 
PropertyInfo prop = modelType.GetProperty(propertyName); 
if(prop != null) { parameterValue = prop.GetValue(model, null); } 
else
{
    FieldInfo field = modelType.GetField(propertyName); 
    parameterValue = field.GetValue(model); 
}

Of course, the above example is an approximation of what's required.

Proposal : Add support for multiple parameters

Problematic Case

Consider the case where you have a stored procedure as follows:
DeleteGroup(AdminUserId, GroupId)

In this peculiar case, we do not have a structure like the following:

class GroupAdmin
{
public int AdminUserId; 
public int GroupId; 
}

Indeed, we consider creating an object for this quite useless... ?

Solution 1

The proposal would be to add an overload to the method :
ExecuteDbProcedureNameAsCallerName(params[] objects...)

Indeed, it would take a variable count of objects (tagged with DbAutoFillAttribute).
It would merge the members.

Possible Issue: Duplicate Members

To avoid this kind of error, allow only DbAnonymousValue instead of complex classes. This forces no-collision.

Or alternatively, allow complex types to merge, but throw exception on duplicate members -> this will throw an exception

Or, just silently override.

Sample

DbAnonymousValue<int> groupId = new DbAnonymousValue<int>("groupId", 2);
DbAnonymousValue<int> adminId = new DbAnonymousValue<int>("adminId", 45);
commandHelper.ExecuteDbProcedureNameAsCallerName(groupId, adminId);

Solution 2

The other proposal would be to add a type DbParameterUnion where objects are added to it but get treated differently than asimple list (flatten the list instead of acting like a structured type).

Possible Issue: Special Treatment

Indeed, I think it would force a special type treatment within the library and therefore is a bigger modification to the core, instead of just a layer of the library.

Sample

DbParameterUnion pu = new DbParameterUnion({"groupId", 2}, {"adminId", 45}); 
commandHelper.ExecuteDbProcedureNameAsCallerName(pu);

Workaround:

Right now, we creates wrapper. It's ugly, but it works...

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.