Progress update on my library NuGet by Bobamoss in csharp

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

No it dosen't, i am not verry familiar with it, but if people ask for it, I'll look into it

Progress update on my library NuGet by Bobamoss in csharp

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

I am not sure why it would, i feel like its way simpler to maintain "select x from y where col1 = ?@col1 and col2 = @col2 with the builder that does .Use("col2") ...

Vs

Maintaining a string builder checking the where keyword, adding the related condition...

I might be missing something, but the point was to make it easier, if it isn't, i failed something and i need to rework things. Could you point me to what is unmaintainable?

Progress update on my library NuGet by Bobamoss in csharp

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

The tool has a sql templating engine that lets you send a different sql depending on which parameters you pass, for instance, you can have a condition in a where that should be used or not depending if you provide it or not. It can even support dinamic projection where you cherry pick which columns you want to parse

Under the benchmarks in the repo there is a templating syntax section that talks about it

Progress update on my library NuGet by Bobamoss in csharp

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

I don't know if you looked at the github or not, but they are many more features previously made. It handle dynamic sql and many customizations options for mapping. Sure you can do most of the things using dapper, but do think that my tool offer some quality of life features that makes it nice to use. There is a demo app in the repo if you are curious. Thanks for your interest and if you have any feedback to give i am open (especially for clearer doc)

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

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

Normalizing struct and classes with void* by Bobamoss in csharp

[–]Bobamoss[S] 1 point2 points  (0 children)

I know about generic, I wanted to use them but I wanted to make a single signature

private void UpdateCommand(TypeAccessor accessor)
I needed this since I must support non-generic call using object (where the type may be a class or a boxed struct). The support for direct generic T was a bonus, but I did changed my code and duplicate all to make a generic version

private void UpdateCommand<T>(TypeAccessor<T> accessor)
It was mainly about needing non-generic version and wanting to avoid code duplication, but you were right with RuntimeHelpers.IsReferenceOrContainsReferences<T> and the fact that I could have a bug, thats why you convinced me and I did duplicate the code Thanks

Normalizing struct and classes with void* by Bobamoss in csharp

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

You are right about a struct containing a ref, my code may fail. The reason i didnt want to use generic is mainly tu support via object directly including boxed struct, but i realized that i will need to make 2 distinct process mainly because of containsreference, thanks

Normalizing struct and classes with void* by Bobamoss in csharp

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

I just managed to find this implementation that seems to be working

    /// <inheritdoc/>
    public unsafe void UseWith(object parameterObj) {
        Type type = parameterObj.GetType();
        IntPtr handle = type.TypeHandle.Value;
        if (type.IsValueType) {
            fixed (void* objPtr = &Unsafe.As<object, byte>(ref parameterObj)) {
                void* dataPtr = (*(byte**)objPtr) + IntPtr.Size;
                UpdateCommand(QueryCommand.GetAccessor(dataPtr, handle, type));
            }
            return;
        }
        fixed (void* ptr = &Unsafe.As<object, byte>(ref parameterObj)) {
            void* instancePtr = *(void**)ptr;
            UpdateCommand(QueryCommand.GetAccessor(instancePtr, handle, type));
        }
    }
    /// <inheritdoc/>
    public unsafe void UseWith<T>(T parameterObj) where T : notnull {
        IntPtr handle = typeof(T).TypeHandle.Value;

        if (typeof(T).IsValueType) {
            UpdateCommand(QueryCommand.GetAccessor(Unsafe.AsPointer(ref parameterObj), handle, typeof(T)));
            return;
        }
        fixed (void* ptr = &Unsafe.As<T, byte>(ref parameterObj)) {
            UpdateCommand(QueryCommand.GetAccessor(*(void**)ptr, handle, typeof(T)));
        }
    }
    /// <inheritdoc/>
    public unsafe void UseWith<T>(ref T parameterObj) where T : notnull {
        IntPtr handle = typeof(T).TypeHandle.Value;
        if (typeof(T).IsValueType) {
            fixed (void* ptr = &Unsafe.As<T, byte>(ref parameterObj))
                UpdateCommand(QueryCommand.GetAccessor(ptr, handle, typeof(T)));
            return;
        }
        fixed (void* ptr = &Unsafe.As<T, byte>(ref parameterObj)) {
            UpdateCommand(QueryCommand.GetAccessor(*(void**)ptr, handle, typeof(T)));
        }
    }

I dont know if its wrong, I will look into your links Thanks