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 6801767
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:08:25+00:00 2026-05-26T19:08:25+00:00

. . List<DailyEntry> entries = null; using (SqlCeDataReader rdr = cmd.ExecuteReader()) { entries =

  • 0
.
.
List<DailyEntry> entries = null;
using (SqlCeDataReader rdr = cmd.ExecuteReader())
{
    entries = rdr.Select(r => new DailyEntry
    {
        ID = int.Parse(r["Col_ID"].ToString()),
        Amount = decimal.Parse(r["Col_Amount"].ToString()),
        Date = DateTime.Parse(r["Col_Date"].ToString()),
        Remarks = r["Col_Remarks"].ToString()
    }).ToList();
}
.
.

extrension method select is

 public static IEnumerable<T> Select<T>(this SqlCeDataReader reader,
                                        Func<SqlCeDataReader, T> projection)
 {
     while (reader.Read())
     {
         yield return projection(reader);
     }
 }

where DailyEntry class is

class DailyEntry
{
    public int ID { get; set; }
    public DateTime Date { get;set; }
    public Site Site { get; set; }
    public decimal Amount { get; set; }
    public string Remarks { get; set; }
}

DailyEntry class has one more property of type Site

class Site
{
    public int SiteID { get; set; }
    public string SiteName { get; set; }
}

Now I want to initialize the Site property of DailyEntry just how all other properties are set in first code snippet..

I am not finding the way?

  • 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-26T19:08:26+00:00Added an answer on May 26, 2026 at 7:08 pm

    Unless I didn’t understand the question, the answer is:

    List<DailyEntry> entries = null;
    using (SqlCeDataReader rdr = cmd.ExecuteReader())
    {
        entries = rdr.Select(r => new DailyEntry
        {
            ID = int.Parse(r["Col_ID"].ToString()),
            Amount = decimal.Parse(r["Col_Amount"].ToString()),
            Date = DateTime.Parse(r["Col_Date"].ToString()),
            Remarks = r["Col_Remarks"].ToString(),
            Site = new Site 
            {
                SiteID = int.Parse(r["Site_ID"].ToString()),
                SiteName = r["name"].ToString()
            }
        }).ToList();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

List<int> a = new List<int>{ 1,1,2,2,3,4,5 }; What's the quickest way to do this
List<int> result1 = (from number in list where number < 3 select number).ToList(); List<int>
List<String> flowers = new ArrayList<String>(); My for loop currently looks like this... for (int
List list = new ArrayList(); String[] test = {ram, mohan, anil, mukesh, mittal}; for(int
List<NastavaIzvjestaj> nastava_izvjestaj = new List<NastavaIzvjestaj>(); var data_context = new DataEvidencijaDataContext(); int pomSum = 0;
List<String> list = new ArrayList<String>(); list.add(One); list.add(null); list.add(Two!); list.add(null); list.add(Three); list.add(null); list.add(Four); list.add(null); I
List<String> nameList = new List<String>(); DropDownList ddl = new DropDownList(); List is populated here,
List<tinyClass> ids = new List<tinyClass(); ids.Add(new tinyClass(1, 2)); bool b = ids.IndexOf(new tinyClass(1, 2))
List<SelectListItem> items = new List<SelectListItem>(); if (a) { SelectListItem deliveryItem = new SelectListItem() {
List<CertMail> lsRecipetNumber = new List<CertMail>(); CertMail class is in data access layer which returns

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.