Click here to Skip to main content
15,905,782 members
Home / Discussions / C#
   

C#

 
QuestionScrollEventType.EndScroll in panel scroll bar did not work Pin
Lawliet072710-Aug-17 19:05
Lawliet072710-Aug-17 19:05 
AnswerRe: ScrollEventType.EndScroll in panel scroll bar did not work Pin
BillWoodruff10-Aug-17 19:40
professionalBillWoodruff10-Aug-17 19:40 
QuestionFind garbage object in form designer file ? Pin
Member 245846710-Aug-17 18:52
Member 245846710-Aug-17 18:52 
AnswerRe: Find garbage object in form designer file ? Pin
BillWoodruff10-Aug-17 19:34
professionalBillWoodruff10-Aug-17 19:34 
GeneralRe: Find garbage object in form designer file ? Pin
Member 245846711-Aug-17 21:52
Member 245846711-Aug-17 21:52 
GeneralRe: Find garbage object in form designer file ? Pin
Pete O'Hanlon15-Aug-17 1:40
mvePete O'Hanlon15-Aug-17 1:40 
GeneralRe: Find garbage object in form designer file ? Pin
Member 245846717-Aug-17 19:33
Member 245846717-Aug-17 19:33 
QuestionAsp.net c# Pin
Hrishikeshkamble10-Aug-17 7:13
Hrishikeshkamble10-Aug-17 7:13 
AnswerRe: Asp.net c# Pin
Richard Deeming10-Aug-17 8:33
mveRichard Deeming10-Aug-17 8:33 
QuestionEmbedded image in Resource reported error ? Pin
Member 24584679-Aug-17 22:06
Member 24584679-Aug-17 22:06 
Questionworking around 'using wrapped MemoryStream immutability ? Pin
BillWoodruff9-Aug-17 17:53
professionalBillWoodruff9-Aug-17 17:53 
AnswerRe: working around 'using wrapped MemoryStream immutability ? Pin
Richard Deeming10-Aug-17 1:16
mveRichard Deeming10-Aug-17 1:16 
GeneralRe: working around 'using wrapped MemoryStream immutability ? Pin
BillWoodruff10-Aug-17 3:47
professionalBillWoodruff10-Aug-17 3:47 
GeneralRe: working around 'using wrapped MemoryStream immutability ? Pin
Richard Deeming10-Aug-17 4:01
mveRichard Deeming10-Aug-17 4:01 
QuestionEntity Framework 4 mapping problems Pin
Member 109427609-Aug-17 13:19
Member 109427609-Aug-17 13:19 
AnswerRe: Entity Framework 4 mapping problems Pin
Gerry Schmitz11-Aug-17 5:55
mveGerry Schmitz11-Aug-17 5:55 
GeneralRe: Entity Framework 4 mapping problems Pin
Member 1094276011-Aug-17 9:11
Member 1094276011-Aug-17 9:11 
Questionquery to retrieve Gujarati Pin
Member 129573749-Aug-17 0:44
Member 129573749-Aug-17 0:44 
AnswerRe: query to retrieve Gujarati Pin
Afzaal Ahmad Zeeshan9-Aug-17 0:53
professionalAfzaal Ahmad Zeeshan9-Aug-17 0:53 
AnswerRe: query to retrieve Gujarati Pin
BillWoodruff9-Aug-17 15:44
professionalBillWoodruff9-Aug-17 15:44 
QuestionC# writing to a csv file, adds an extra column Pin
Member 128805958-Aug-17 23:22
Member 128805958-Aug-17 23:22 
AnswerRe: C# writing to a csv file, adds an extra column Pin
Richard Deeming9-Aug-17 1:08
mveRichard Deeming9-Aug-17 1:08 
Your ToCsv method returns the string representation of the value of every public field and property of the entity you pass in.

The value System.Data.Linq.EntitySet`1[BookLendingLib.Models.RentedBook] suggests your entity contains a navigation property which returns a collection of RentedBook entities. This is a property, just like any other, and so will be included in the output.

Your code will also not work correctly if any property value contains a comma.

Try using a proper CSV library, like CsvHelper[^]:
C#
private void ExportBookDb(string saveFilePath)
{
    using (var bDC = new BookDBDataContext())
    using (var textWriter = File.CreateText(saveFilePath + ".csv"))
    using (var csv = new CsvWriter(textWriter))
    {
        csv.WriteRecords(bDC.Books);
    }
}




"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer


GeneralRe: C# writing to a csv file, adds an extra column Pin
Member 128805959-Aug-17 5:23
Member 128805959-Aug-17 5:23 
QuestionHow to implement an existing methods in Visual Studio? Pin
gcobza20105-Aug-17 3:56
gcobza20105-Aug-17 3:56 
AnswerRe: How to implement an existing methods in Visual Studio? Pin
OriginalGriff5-Aug-17 4:40
mveOriginalGriff5-Aug-17 4:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.