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

  • SEARCH
  • Home
  • 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 7488725
In Process

The Archive Base Latest Questions

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

I’m working on a project that connects to Oracle. It Brings back data through

  • 0

I’m working on a project that connects to Oracle. It Brings back data through a dataset. I use Linq to bind it to a collection and throw it back to be read by json. It works great but I can’t help but think – there’s got to be a better way to do this. Here’s an example of what I do. I hope it helps others. Dsp is Dataset.

List<Information> lstSearch = null;
     lstSearch = (from l in dsp.Tables[0].AsEnumerable()

                         select new Information
                         {

                             application_id = l["APPLICATION_ID"].ToString(),
                             hospital_name_1 = l["HOSPITAL_NAME_"].ToString(),
                             physical_address = l["PHYSICAL_ADDRESS"].ToString(),
                             // may have to add more here...

                         }).ToList<Information>();

// serialize and send back as a json string
System.Web.Script.Serialization.JavaScriptSerializer oSerializer =
                    new System.Web.Script.Serialization.JavaScriptSerializer();

                string sJSON = oSerializer.Serialize(lstSearch.First());

Theoretically, yes works. The “information” collection matches the html “name” tag of each control on the page which provides a nice robust binding. My concern lies with having
to go through each field name in order to populate the List<> object.

Isn’t there a specific where clause in where the collection (get/set) property matches the dataset column name thus populating the collection only if the column name (not the value) matches the data row column?

  • 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. Editorial Team
    Editorial Team
    2026-05-29T15:01:12+00:00Added an answer on May 29, 2026 at 3:01 pm

    I’d recommend AutoMapper … see this question.

    Here’s a very simple example. Make sure that your .NET type exactly mirrors the structure of your DB object or AutoMapper will not work as advertised:

    namespace EnumerableDT
    {
        class Program
        {
            public class Information
            {
                public int APPLICATION_ID { get; set; }
                public string HOSPITAL_NAME { get; set; }
                public string PHYSICAL_ADDRESS { get; set; }
                public string SOME_OTHER_FIELD { get; set; }
            }
    
            static DataSet dsp = new DataSet();
    
            static void Main(string[] args)
            {
                dsp.Tables.Add(BuildDataTableStructure());
                dsp.Tables[0].Rows.Add(BuildRow());
    
                AutoMapper.Mapper.Reset();
                AutoMapper.Mapper.CreateMap<IDataReader, Information>();
    
                var il = AutoMapper.Mapper.Map<IDataReader, IList<Information>>(dsp.Tables[0].CreateDataReader());
    
                Console.ReadLine();
            }
    
            static DataTable BuildDataTableStructure()
            {
                var dt = new DataTable();
                var dc = new DataColumn("APPLICATION_ID", typeof(int));
                dt.Columns.Add(dc);
                dc = new DataColumn("HOSPITAL_NAME", typeof(string));
                dt.Columns.Add(dc);
                dc = new DataColumn("PHYSICAL_ADDRESS", typeof(string));
                dt.Columns.Add(dc);
                dc = new DataColumn("SOME_OTHER_FIELD", typeof(string));
                dt.Columns.Add(dc);
    
                return dt;
            }
    
            static DataRow BuildRow()
            {
                DataRow dr = dsp.Tables[0].NewRow();
                dr["APPLICATION_ID"] = 1;
                dr["HOSPITAL_NAME"] = "The Hospital";
                dr["PHYSICAL_ADDRESS"] = "123 Main St.";
                dr["SOME_OTHER_FIELD"] = "Some Other Data";
    
                return dr;
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am trying to understand how to use SyndicationItem to display feed which is
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I want use html5's new tag to play a wav file (currently only supported
I have a French site that I want to parse, but am running into
I am currently running into a problem where an element is coming back from

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.