vircomopensource / dbautofill Goto Github PK
View Code? Open in Web Editor NEWA minimalistic database ORM.
License: MIT License
A minimalistic database ORM.
License: MIT License
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.
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.
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... ?
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.
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.
DbAnonymousValue<int> groupId = new DbAnonymousValue<int>("groupId", 2);
DbAnonymousValue<int> adminId = new DbAnonymousValue<int>("adminId", 45);
commandHelper.ExecuteDbProcedureNameAsCallerName(groupId, adminId);
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).
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.
DbParameterUnion pu = new DbParameterUnion({"groupId", 2}, {"adminId", 45});
commandHelper.ExecuteDbProcedureNameAsCallerName(pu);
Right now, we creates wrapper. It's ugly, but it works...
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.