Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 187523
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T15:50:19+00:00 2026-05-11T15:50:19+00:00

I have a rather peculiar data source I have to work with (an interface

  • 0

I have a rather peculiar data source I have to work with (an interface to an accounting application actually). While it is pretty powerful, I have to jump through pretty many hoops to get the data I want out of it. For example, if I want to get the contents of a table and specify which columns it should return, I have to iterate through the .Columns collection and call .SetVisible() to the ones I want.

Currently we have a method that wraps around this and allows us to specify things in an more simple way, but the parameter list to that function is growing fast, and most of the time we only need to specify a few of them when we call it. In short – it’s an inflexible solution.

The first solution that came to my mind was something like this:

DataTable result = DataSourceWrapper.StartQuery('TableName')     .SetVisibleColumns('Col1', 'Col2', 'Col3')     .SetCriteria('CriteriaName', 'Param1Name', CriteriaParam1, 'Param2Name', CriteriaParam2)     .SetFilter('Col4 = ? AND Col5 = ?', FilterParam1, FilterParam2)     .SetReportParams('Param1Name', ReportParam1, 'Param2Name', ReportParam2)     .Execute(); 

Criteria, Filters and ReportParams are some things specific to the application and I will not discuss them here. But the general idea is like this. It’s practically analogous to calling a method, except you can choose which parameters to specify (by calling specific methods) and have a bit more IntelliSense assistance. And you can also play with the order of the method calls.

Note that SetFilter() has an expression to parse. This is another thing that the DataSource makes difficult – it can process expressions quite nice, but you have to pass them as a tree of special objects, which again is pretty lengthy to write. In a previous question I asked for help on parsing such expressions. The current wrapper-method has a homebrew expression parser, which can parse simple expressions, but I thought of making the support for them more complete.

In that question, the Irony project was suggested. After checking it out I decided that it was indeed suited for this need. But after a while it dawned on me, that it was even more powerful than that. Why not make my own query language suited for exactly this task? The above would then look like:

DataTable result = DataSourceWrapper.Query(@'     SELECT Col1, Col2, Col3     FROM TableName     WITH CRITERIA CriteriaName(Param1Name={0}, Param2Name={1})     WITH REPORTPARAMS (Param1Name={2}, Param2Name={3}     WHERE Col4 = {4} AND Col5 = {5}',     CriteriaParam1, CriteriaParam2,     ReportParam1, ReportParam2,     FilterParam1, FilterParam2 ); 

But… would this not be an overkill? What are the pros and cons of either approach? What I see is:

Pro DSL:

  • query more concise;

Pro Methods:

  • More IntelliSense support;
  • Method names/parameter names (and comments) make less need for documentation (DSL will have to be documented thoroughly);
  • Might be quicker to create? I’ve never created my own DSL, so I don’t know how much work that is. Irony seems to take a lot of the burden from my shoulders, but how much is still left there?

Added: To clarify, both approaches will be used only by coders. External people and business analysts will not use it.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T15:50:20+00:00Added an answer on May 11, 2026 at 3:50 pm

    You have to be careful about what you call a DSL. See Martin Fowler’s Bliki post on DSL. Your example of the method chaining is very close to an internal DSL. Modify it slightly and it is:

    DataTable result = DataSourceWrapper.Query('TableName')     .With(new Columns('Col1', 'Col2', 'Col3'))     .Where(new AndCritera('CriteriaName',         new Criterion('Param1Name', CriteriaParam1),         new Criterion('Param2Name', CriteriaParam2))     .Filter(         new Filter('Col4').Equals(FilterParam1),         new Filter('Col5').Equals(FilterParam2))     .With(         new ReportParam('Param1Name', ReportParam1),         new ReportParam('Param2Name', ReportParam2)); 

    That being said, this is still very much within the C# realm, and only programmers will be able to write these queries. If your requirements are pushing you toward making queries available to non-programmers, then you might consider undergoing the effort of creating an external DSL as you specified in the second example.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 89k
  • Answers 90k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer FYI, Using unescaped in any JavaScript script causes this issue… May 11, 2026 at 5:59 pm
  • Editorial Team
    Editorial Team added an answer C++ is a compiled language, and thus, there is no… May 11, 2026 at 5:59 pm
  • Editorial Team
    Editorial Team added an answer This is valid CSS. It selects EVERY element and resets… May 11, 2026 at 5:59 pm

Related Questions

I'm working on a project at the moment where I've come up against a
I have a rather large file (150 million lines of 10 chars). I need
I have a rather classic UI situation - two ListBoxes named SelectedItems and AvailableItems
I have a rather weak understanding of any of oracle's more advanced functionality but
I have a rather big number of source files that I need parse and

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.