cmeeren / Facil

Facil generates F# data access source code from SQL queries and stored procedures. Optimized for developer happiness.
MIT License
140 stars 7 forks source link

Question: Can the tool be used to generate a select without any conditions? #20

Closed costa100 closed 2 years ago

costa100 commented 2 years ago

Hello,

Sometimes there are small tables that I want to load in the memory. Is there a way to generate the type that selects all records from the table, something like - type: select.

Thanks

cmeeren commented 2 years ago

Not currently. I use these kinds of queries myself, but since they're so trivial (SELECT * FROM TableName), I haven't bothered to create a table script type for them. But if you want, I can probably add it.

costa100 commented 2 years ago

If it's not too much work... I would appreciate if you add it. I am very new to your library, I just started to explore it today (yesterday that is), so off the top of my had I don't know how much boilerplate code one would have to write for select * from TableName to give you a more informed answer.

cmeeren commented 2 years ago

The difference is that instead of having the following in facil.yaml:

- type: selectAll

Then you have an .sql file with the following:

SELECT * FROM TableName

As you can see, there is basically no difference. That's why I'm not sure there's much point in adding it.

Try out the library for a week, and let me know what you think after that. 👍

cmeeren commented 2 years ago

Thinking about it, there is one difference: With the tableScripts option, the select columns would be explicitly specified (instead of * in the SQL file I showed). That is a good practice. So perhaps I should add it after all. I'll look into it.

cmeeren commented 2 years ago

Releasing in v2.1.0, which is in the pipeline now.

costa100 commented 2 years ago

Thank you!

Does version 2.1.0 support .Net 5?

cmeeren commented 2 years ago

No, from 2.0.0 it's .NET 6 only.

costa100 commented 2 years ago

If it is not too much to ask and it doesn't require too much work, could you please include this feature in the version that supports .Net 5? Right now I am stuck to .Net 5... But I understand if you don't want to do it. Thanks

cmeeren commented 2 years ago

Sorry, I simply don't have the capacity to backport stuff. I recommend you transition to .NET 6. It is probably a trivial change; just change net5.0 to net6.0 in your project files and install the .NET 6 runtime or hosting bundle in the environments where you publish your code.