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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T18:56:57+00:00 2026-05-15T18:56:57+00:00

at present, I have: string outputRow = string.Empty; foreach (var entityObject in entityObjects) {

  • 0

at present, I have:

        string outputRow = string.Empty;
        foreach (var entityObject in entityObjects)
        {
            outputRow = entityObject.field1 + "," + entityObject.Field2  etc....
        }

I’m still new to the Entity Framework, is there a quicker 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-15T18:56:58+00:00Added an answer on May 15, 2026 at 6:56 pm

    Sample code that shows a simple yet powerful way of accomplishing what you want with no need to hard code property names (using reflection):

     /// <summary>
     /// Creates a comma delimeted string of all the objects property values names.
     /// </summary>
     /// <param name="obj">object.</param>
     /// <returns>string.</returns>
     public static string ObjectToCsvData(object obj)
     {
         if (obj == null)
         {
             throw new ArgumentNullException("obj", "Value can not be null or Nothing!");
         }
      
         StringBuilder sb = new StringBuilder();
         Type t = obj.GetType();
         PropertyInfo[] pi = t.GetProperties();
      
         for (int index = 0; index < pi.Length; index++)
         {
             sb.Append(pi[index].GetValue(obj, null));
      
             if (index < pi.Length - 1)
             {
                sb.Append(",");
             }
         }
      
         return sb.ToString();
     }
    

    More on this:

    Objects to CSV

    How can i convert a list of objects to csv

    Are there any CSV readers/writer lib’s in c#

    Writing a CSV file in .net

    LINQ to CSV : Getting data the way you want

    LINQ to CSV library

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

Sidebar

Related Questions

I have an ordered string that I need to present to a user: ABCCDDCBBBCBBDDBCAAA
I have to write a program to check if any random string is present
I have a couple of views which present data from a CoreData entity in
I have a string $VAR=I-UAT; in my shell script code. I need a conditional
What i Have: At present i have a String variable i-e: String str_StoreValue; I
I have big string in that I need to check if number is present
Assume that I have the following string: present present present presenting presentation do do
I have a String 0214 i would like te present this as 02:14 is
At present I have a TestNG project that calls a JBoss RESTEasy web service.
At present we have a denormalised database. ie Name|NameID|EmployeeID|EmployeeType I'm normalising the database to

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.