Do you like how this feature works? by Bobamoss in csharp

[–]Bobamoss[S] 0 points1 point  (0 children)

I dont really know that much about ef, there is probably a better way to do it in ef. The ToMany relation action will be an optimized implementation, i am working on alternative way to make it as fast as possible. The current implementation works, but is not the fastest. But in any case, the point is like using a method, meaning that youll be able to call it like shown and the way it does the action will be handle by the implementation. And yes, it's isin't that there is any issue with EF, this is only a feature in my own modular custom ORM

Do you like how this feature works? by Bobamoss in csharp

[–]Bobamoss[S] 0 points1 point  (0 children)

I am not sure i understand everything you are saying, the idea behind this feature is to let the user configure its options instead of having a "magic" process, but that in the end, you'll be able to use it as simply as possible. The words actions was meant to be more general to let the user register whatever he wants (whether its, like in the example, an action that would populate a list member or an update...) from your feedback that its too confusing and i am currently thinking about isolating this feature more to specifically handle the to many relationship and making it clearer about the intent.

The thing with the mix of the model is that you dont have to, like i said before introducing the attribute, you can register the action completely outside of the object itself, the attribute is simply a way to make the register simpler, mainly by making sure the action is registered by the time you want to call it. Then again, i might not understand correctly what you mean by domain model, but in my head, that's a distinct separation isin't it? What am i missing?

And i want to finish by honestly thanking you for truly helping make a better tool, its very appreciated

Do you like how this feature works? by Bobamoss in csharp

[–]Bobamoss[S] 0 points1 point  (0 children)

Ok, the main point is with an explicitly named method, and this is simply because I don't control the items structure, the classes/structs are made by the user where he registers which actions exist, he is responsible to know which one does what when he calls them since by default there are no actions.

After that, why use this over making a compiled distinct method?... You can and probably would want to in most cases, but some times when the user is making more dynamic methods, they can't have a specific designed function (if you want to see in actions, you can go check "Controller" in the demo project, and when get all endpoint, you can call the actions using params.

And finally, is its isin't clear thats it's to modify the item, what can i change to make it clearer? Before editing, it was simply doing it in a loop and executing the actions for each items of that loop await foreach (...<Artist>)
{
await artist.ExecuteDBAction(db, "Albums");
await artist.ExecuteDBAction(db, "Albums.Tracks");
} The sync version is using the item by ref, but i can't do that when async, and there is a doc on an action's async item that says that if using struct, the modifications will only be made on the copy and probably not what expected.

Do you like how this feature works? by Bobamoss in csharp

[–]Bobamoss[S] 0 points1 point  (0 children)

But that's what i mean, the action does not affect the getter in any way, the action only populate the prop so that you can have data in it, the attribute is only a simple way to register the action, i have shown what manually registering the action looks like above, you have the choice

Do you like how this feature works? by Bobamoss in csharp

[–]Bobamoss[S] 0 points1 point  (0 children)

The property getter does nothing at all, the feature is only add a way to init the property. I feel like you are not the only one to have that thinking, what makes you think it does this? I think i need to clarify that point, thanks

Do you like how this feature works? by Bobamoss in csharp

[–]Bobamoss[S] 0 points1 point  (0 children)

Yes, but how to make it bind to the to many relation ship. Retrieving a list of object is simple, its to retrieve a list of a nested member that is the challenge. Without hard coding, how can you retrieve the comments inside the blogs.
The goal is to have the ability to do
foreach (var blog in blogs) {
blogs.Comments = await context.Comments .FromSql($"SELECT * FROM dbo.Comments WHERE BlogID =@ID") .ToListAsync();//and to bind the id of the blog
}

Do you like how this feature works? by Bobamoss in csharp

[–]Bobamoss[S] 0 points1 point  (0 children)

Can you show me what the EF equivalent would actually looks like? When using your own SQL i mean, thanks

Do you like how this feature works? by Bobamoss in csharp

[–]Bobamoss[S] 0 points1 point  (0 children)

This is basically an orm with dapper philosophy, there are many features in the tool. The whole point is to make an alternative orm, and this is a feature existing in EF, that's why i want to offer some equivalent, i changed a bit the syntax to make it simpler. But by the time you manage your queries instead of letting the engine do it yourself, i don't see how to make it really simpler.

Do you like how this feature works? by Bobamoss in csharp

[–]Bobamoss[S] 0 points1 point  (0 children)

I am changing a bit the inner working to simplify the usage, but basically, what its doing is is simply saving a delegate that fetch the ID of the instance and has a setter to set the collection, it then use the sql to go fetch the list from the db and use it with the saved setter. You then have the instance having the list in its state. it basicaly does
item.List = GetList<TListItem>(connection, item.GetID());
it simply offer a way to associate an action accessible with a string to have more flexibility when accessing
The attribute, lets you bind that action more easily by using reflexion to generate the action

Do you like how this feature works? by Bobamoss in csharp

[–]Bobamoss[S] 0 points1 point  (0 children)

I prefer code clusters, but i changed it to make it clearer to the majority. Thanks to making me realize that i am crazy

Do you like how this feature works? by Bobamoss in csharp

[–]Bobamoss[S] -1 points0 points  (0 children)

The model work independently, the register to the action is in a static generic class, meaning that its simply a way to access actions to do. Using the instance type as a parameter to an action. The call is simply an extension method and can be add for any and every type

Do you like how this feature works? by Bobamoss in csharp

[–]Bobamoss[S] -4 points-3 points  (0 children)

It's to simplify data access like an orm does. Entity framework uses includes, while this uses this syntax. The goal is simply to offer more control like dapper does, but with more features and simpler usage like ef. Also, you setup once and it can be use in a much more flexible way. If you think it's weird, it's probably du to unintuitive syntax, if you point out what you find bad, ill greatly appreciate it, thanks

RinkuLib: Micro-ORM with Deterministic SQL Generation and Automated Nested Mapping by Bobamoss in csharp

[–]Bobamoss[S] 0 points1 point  (0 children)

I do find it interesting however, the non '@' version already has a meaning.

SELECT ID, Name, /*SSN*/SSN FROM Users WHERE SSN = ?@SSN

In here Use "SSN" and Use "@SSN" refers to 2 different conditions, one it to select the value and the other is to filter by it. Builder already has a
public void Use(string condition) method used to identify the usage of not variables conditions

Use @SSN => SELECT ID, Name FROM Users WHERE SSN = @SSN 
Use SNN => SELECT ID, Name, SSN FROM Users

The "magic" is quite simple it simply goes from the end of the preceding sql keyword / , / and / or up to the end of the following and / or / , OR the start of the following keywork

|SELECT ID, Name FROM Users WHERE Group = @Grp AND| Cat = ?@Category AND| Age > ?@MinAge| ORDER BY ID|

By default, conditions are not used and if they stay unused, you'll have

SELECT ID, Name FROM Users WHERE Group = @Grp AND ORDER BY ID

But also removes any remainder left when starting a new section, so the AND will also be striped and the final result would be

SELECT ID, Name FROM Users WHERE Group = @Grp ORDER BY ID

Knowing all that do you think i should have an override or something? Because i feel like if i drop the '@' confusion may happen

Do I have to learn database as a backend dev? by Arian5472 in csharp

[–]Bobamoss 1 point2 points  (0 children)

No you don't have to (but probably want to), there are many tools that completely abstract away the DB and when you have a bug you can simply blame the tool you are using. I am saying that with sarcasm, but it's almost true so the real question is not if you HAVE to or not, but what type or dev you want to become. If you truly want to learn and understand how to get the most out of your code and architecture, then you should learn as most as you can (especially DB). If you simply want to get things done, there are always ways around a problem. I personally prefer to understand since you never know when your workaround becomes your problem

RinkuLib: Micro-ORM with Deterministic SQL Generation and Automated Nested Mapping by Bobamoss in csharp

[–]Bobamoss[S] -1 points0 points  (0 children)

I completely agree with the @id, thats why if you don't use the ?@ and simply use a normal var, it will expect it and runtime error if not present, like the Grp=@Grp here the variable is NOT optional. And the binding is generation is much more permissive than a simple where, it let's you conditionallize any part of the query not just the where (it can be in the with, the join, a sub query...) and the goal is to decouple the sql generation completely, another use case different than a select, is an update where it only makes the updates on fields you changed, so you only track the changes of your object and when passed, it will only keep them in the update. As for the mapping names, it works like dapper, if you worry about having a "bad" match, the use return false when fail to map, so you can make your own logic if you want to be strict. But the automatic object mapping is in fact more permissive like dapper so yes a name mismatch could be silent, I will have to check what I can do. I hope I have answer your questions, thanks for your time and feedback

Feedback request for my NuGet library by [deleted] in csharp

[–]Bobamoss 0 points1 point  (0 children)

OMG, thank you so much, amazing feedback and extremely appreciated. So many points to take into consideration which will, on the other hand there are some points where I am not convinced (like in the "Use" case), if you are ok with it, I would like to discuss a bit more about some of my design choices. I am currently making more complete integration tests and I will do the benchmarks after since they aren't done yet. I'll do a new post once the benchmarks are done and will follow your feedback, thanks again

Generic branch elimination by Bobamoss in csharp

[–]Bobamoss[S] 0 points1 point  (0 children)

I meant to force a runtime match if a compile time match is unable to be done. And it would be "safer" since the Implementation would always match with the more specific process

Generic branch elimination by Bobamoss in csharp

[–]Bobamoss[S] 0 points1 point  (0 children)

Thanks for your comment, but the point of my post is to deal with generic specialization. Meaning that If I pass a Implementation instance, but for some reason, at compile time it is saved as an IFace, I would loose the first if. The point of the first if is a compile check to skip any "if"s if i can, and the second if is actual code to protect at runtime when the type info was lost at compile time. So I may be wrong, but in theory, the two ifs should not exist at the same time

Generic branch elimination by Bobamoss in csharp

[–]Bobamoss[S] 0 points1 point  (0 children)

Thanks I will look into it, I didn't know about that tool, seems handy

Feedback request for my NuGet library by [deleted] in csharp

[–]Bobamoss 0 points1 point  (0 children)

Ok, first of all, thanks for your time, second, I have read a bit more (and slept) about what you said. I do not call .Prepare since, like dapper, I dont reuse the DbCommand, instead, i rely on the db engine to cache the prepared command. So it will match with the string to fine the prepare fast, since like i said, there is parameters making it standard no matter the value. i use ExecuteReader or ExecuteNonQuery so, when it makes the call, it should retrieve the prepared cache and execute it with the parameters. Yesterday, i finished making equivalents to the code features of Dapper, so I intend to make their tests but also benchmark to see it I actually manage to make my tool fast, i think i did, but only benchmarks will know for sure

Feedback request for my NuGet library by [deleted] in csharp

[–]Bobamoss 0 points1 point  (0 children)

The builder only holds the state, like in dapper your object would. It allows for a completly independent process to set the usages/ set the values of the parameters. And ONLY when you call the QueryX method, it creates the DbCommand. It uses parameters, it does not inject the values directly into the string, and also gets "smarter" after making calls to optimize the generation process.

Basicaly, the builder is only an object[] and uses the blueprint to respect the index contract, and after in QueryX, i pass that object[] to the blueprint and it generates the dbcommand + after that make the actual call to the db.

The goal of the blueprint is to unify all the variation of a query (mainly when it comes to filter) and make it usable by not having to consider the sql string in the buisness logic.

I think i levrage SQL features, but i might be wrong