سؤال

I have an SQL script file (that is, a file with a .sql extension) and I want to execute it using PetaPoco in C#. Is that possible?

هل كانت مفيدة؟

المحلول

You can read the file and then execute the contents:

string sqlstmt = System.IO.File.ReadAllText(@"C:\Users\Public\something.sql");
db.Execute(sqlstmt);

نصائح أخرى

Answer is no. Which you would know if you tried it. PetaPoco is an ORM - it maps relational tables to objects. Running a random SQL Script does not involve mapping tables to objects. So, your question is like asking if you can use a hammer to drive to the store.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top