C
C#3mo ago
MistSlay

Writing SQL code

Im not used to coding with SQL i wrote a code in C sharp but im not sure how and where to implement it into my current database any help appreciated
23 Replies
Angius
Angius3mo ago
What is your question, actually? How can you use SQL to make your C# application query the database?
MistSlay
MistSlay3mo ago
its more that i made a code on c sharp and am trying to find a way to make it work for my database so it is like a interactive database
Angius
Angius3mo ago
So, just connecting your C# project to an SQL database?
MistSlay
MistSlay3mo ago
im really new to SQL and dont understand it very well if thats possible
Angius
Angius3mo ago
Sure is
Pobiega
Pobiega3mo ago
SQL is just a language for "talking" with databases, or issue commands to it. C# has plenty of ways to do that.
Angius
Angius3mo ago
If you want to write SQL specifically, Dapper can let you execute SQL commands on any given database If you want to not write any SQL, Entity Framework Core lets you connect to an SQL database and will generate SQL queries for you, from your C# code
Jimmacle
Jimmacle3mo ago
did you go through the resources provided the last time you asked this question?
MistSlay
MistSlay3mo ago
yea i did but it didnt make much more clear for me ill behonest i was able to do the questions but its when i try to implement them myself my brain goes blank on how i should do it
Jimmacle
Jimmacle3mo ago
where specifically are you getting stuck? have you connected to your database? can you make some queries but not others?
MistSlay
MistSlay3mo ago
i have my database open i havent tried running any queries as i dont think its acc functional its more just the framework of it if that makes sense
Jimmacle
Jimmacle3mo ago
i mean in your C# code
MistSlay
MistSlay3mo ago
i dont know how to acc connect it i was going to try se if i can use the Enitiy framework core that zzzzzzzzzz recomended
Jimmacle
Jimmacle3mo ago
i thought this was a school project, do you have specific requirements about what to use? your teacher should be giving you that kind of information
MistSlay
MistSlay3mo ago
he isnt the best teacher ill be honest i think he just wants it done aslong as there is no plagerisum
Pobiega
Pobiega3mo ago
EF is more... "magical" than the alternatives. If you have a poor understanding of databases, SQL etc I'm not sure I'd recommend using EF you wont really understand whats going on
Jimmacle
Jimmacle3mo ago
you need to know how databases work before being able to use EF properly the conclusion we came to earlier is something more basic like ADO.NET is what you should look at
Angius
Angius3mo ago
Unless the teacher specifically requests ADO, I'd at least go with Dapper .Query<Person>("SELECT * FROM People LIMIT 1") will be much easier to understand than the reader.ReadInt32() tomfuckery
Pobiega
Pobiega3mo ago
its not really either or. Dapper is just a thin wrapper on top of ADO but I agree, use dapper
Jimmacle
Jimmacle3mo ago
even better, ask your teacher before you make an assumption :when:
Pobiega
Pobiega3mo ago
that too :p
Angius
Angius3mo ago
100%
MistSlay
MistSlay3mo ago
True im gonna during the next lecture thank you for the help