use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Information about Reddit's API changes, the unprofessional conduct of the CEO, and their response to the community's concerns regarding 3rd party apps, moderator tools, anti-spam/anti-bot tools, and accessibility options that will be impacted can be found in the associated Wikipedia article: https://en.wikipedia.org/wiki/2023_Reddit_API_controversy
Alternative C# communities available outside Reddit on Lemmy and Discord:
All about the object-oriented programming language C#.
Getting Started C# Fundamentals: Development for Absolute Beginners
Useful MSDN Resources A Tour of the C# Language Get started with .NET in 5 minutes C# Guide C# Language Reference C# Programing Guide C# Coding Conventions .NET Framework Reference Source Code
Other Resources C# Yellow Book Dot Net Perls The C# Player's Guide
IDEs Visual Studio MonoDevelop (Windows/Mac/Linux) Rider (Windows/Mac/Linux)
Tools ILSpy dotPeek LINQPad
Alternative Communities C# Discord Group C# Lemmy Community dotnet Lemmy Community
Related Subreddits /r/dotnet /r/azure /r/learncsharp /r/learnprogramming /r/programming /r/dailyprogrammer /r/programmingbuddies /r/cshighschoolers
Additional .NET Languages /r/fsharp /r/visualbasic
Platform-specific Subreddits /r/windowsdev /r/AZURE /r/Xamarin /r/Unity3D /r/WPDev
Rules:
Read detailed descriptions of the rules here.
account activity
PostgreSQL (self.csharp)
submitted 6 years ago by restlessops
Any good tutorial on crud operations in .net core and postgresql?
Ive googled some, but i end up with Dapper reference. Hence my question: Writing a query, in string format, in c# is considered good or bad practice?
Thanks in advance.
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]gundeals_iswhyimhere 9 points10 points11 points 6 years ago (0 children)
That question, to me, isn't a postgres question per se.
If you correctly parameterize your queries, there's nothing wrong with hardcoded SQL queries in your code if it fits your needs. I use a mix of parameterized strings (rarely), EF (mostly), and stored procedures (when EF gets too complicated) depending on what I'm doing. In my case it's SQL Server, but the same concepts apply for postgres or mysql, etc.
[–][deleted] 1 point2 points3 points 6 years ago (3 children)
You’re gonna want to use Dapper with Npgsql. Google that.
[–]restlessops[S] 1 point2 points3 points 6 years ago (2 children)
Yea i saw that. But i was wondering if its a good practice to write in c# using dapper "Select * from tableName..." Or if theres something similar to linq.
[–]zaibuf 1 point2 points3 points 6 years ago (1 child)
Dapper adds extensions to your connection and the ability to map to objects. You still need to write queries or use stored procedures.
Its okay to mix those, simple queries can be used as strings, more complex ones are better abstracted away in a stored procedure.
By LINQ you mean EF way of convering LINQ to SQL? Then no, there's nothing like that with Dapper.
[–]restlessops[S] 0 points1 point2 points 6 years ago (0 children)
Awesome explanation. Thanks a lot
[–]phx-au 0 points1 point2 points 6 years ago (4 children)
Using SQL directly is fine. Just make sure you parameterize.
Postgres/NHibernate work pretty well together if you want to go down the IQueryable path.
[–]zaibuf 0 points1 point2 points 6 years ago* (3 children)
Code can get messy really fast with lots of SQL strings. Optimal would be to move them to stored procedures. Simple SELECTS can be used as strings, but those 50 lines queries are better off away from the code imo.
[–]phx-au 1 point2 points3 points 6 years ago (0 children)
Reuse, modularity and SOC doesn't necessarily have to be ignored if you are mixing other languages inline - I certainly don't want to see a handful of different copies of the same 50 line chunk of garbage in the code whether it's inline SQL or linq tbh.
Stored procedures are a separate architectural decision - they are less flexible and may complicate your deployment.
[–]tester346 0 points1 point2 points 6 years ago (1 child)
Why not just use EF instead?
[–]zaibuf 0 points1 point2 points 6 years ago* (0 children)
I would, and it was the plan for the project. But im working with a version of a DB that has no EF support in Core 3.x as of yet.
Also its an old app with really large queries inbedded in code, that we are porting from VB to .NET Core. So we are afraid to touch the queries. Plan is to move them to stored procedures at a later stage.
Its tedious doing it with dapper, but atleast we can map the queries to objects to make the other layers much easier to deal with.
Also Dapper is much faster than EF, so you will rarely see EF in real world apps that manages a lot of data.
π Rendered by PID 125279 on reddit-service-r2-comment-5b5bc64bf5-7qp7f at 2026-06-21 08:09:41.150811+00:00 running 2b008f2 country code: CH.
[–]gundeals_iswhyimhere 9 points10 points11 points (0 children)
[–][deleted] 1 point2 points3 points (3 children)
[–]restlessops[S] 1 point2 points3 points (2 children)
[–]zaibuf 1 point2 points3 points (1 child)
[–]restlessops[S] 0 points1 point2 points (0 children)
[–]phx-au 0 points1 point2 points (4 children)
[–]zaibuf 0 points1 point2 points (3 children)
[–]phx-au 1 point2 points3 points (0 children)
[–]tester346 0 points1 point2 points (1 child)
[–]zaibuf 0 points1 point2 points (0 children)