0

Using Firebird and the .Net Firebird provider. Looking for something like:

using (var cmd = new FbCommand()) {

   var parser = new FbParser(someSqlText);

   // Add a filter to the where clause. May need code for adding a "where" if there is none or adding an "and" statement, etc.
   parser.MainWhereClause += "someTable.someField = @someParam";

   // Default some orderby. Add one, etc?
   parser.OrderByClause = parser.OrderByClause ?? "customer.name";

   parser.SelectFields.Add("customer.phone");
   if (parser.GroupByFields.Any()) {
      parser.GroupByFields.Add("customer.phone");
   }

   cmd.CommandText = parser.ToString();

   // FbCommand does have a Prepare() method and that does allow that object to know the parameters, but they are private and not accessible.
   foreach (var parameterName in parser.Parameters) {
      cmd.Parameters.Add(parameterName).Value = GetSomeValue(parameterName);
   }

Anything like this out there? I am finding this for other SQL flavors, but nothing understands the FB syntax like the concatenations, CTEs, derived tables, etc.

Paul
  • 5,700
  • 5
  • 43
  • 67
  • I don't really know much about .Net or firebird, but did you try looking for a Firebird compatible ORM? – MikeVelazco Aug 31 '17 at 19:05
  • Yes, there is one. I haven't used anything ORM related and didn't even think to look for that. I will try a sample console app and install it and see if it has anything I can use. – Paul Aug 31 '17 at 19:25
  • "concatenations, CTEs, derived tables" are standard SQL, aren't them ? – Arioch 'The Sep 01 '17 at 08:12
  • Not the same. For example, the SQL Server parser I found could not parse a statement like `select field from (some subselect statement) join foo ... ` Because the syntax is different with each type of SQL. Also, SQL Server concatenations use `+` while Firebird uses `||`. This caused an error in the parser. – Paul Sep 01 '17 at 12:05

0 Answers0