Note that there are some explanatory texts on larger screens.

plurals
  1. POFileHelpers - WriteStream Not Writing All The Data To Stream
    primarykey
    data
    text
    <p>I am writing an MVC application that will export data to a CSV file. I have some data pulled via a Linq query, and the query pulls all the correct records, but the data is not being completely written to the stream. I get partial or no data at all when I check the stream before it is returned to the user.</p> <p>The FileHelpers Class</p> <pre><code>Imports FileHelpers &lt;DelimitedRecord(",")&gt; _ Public Class AssetSearchFileHelper &lt;FieldOrder(1), FieldQuoted()&gt; _ Public AssetNumber As String &lt;FieldOrder(2), FieldQuoted()&gt; _ Public AssetDescription As String &lt;FieldOrder(3), FieldQuoted()&gt; _ Public SerialNumber As String &lt;FieldOrder(4), FieldQuoted()&gt; _ Public ClassName As String &lt;FieldOrder(5), FieldQuoted()&gt; _ Public ManufacturerName As String &lt;FieldOrder(6), FieldQuoted()&gt; _ Public ModelName As String &lt;FieldOrder(7), FieldQuoted()&gt; _ Public LocationName As String &lt;FieldOrder(8), FieldQuoted()&gt; _ Public AssignedTo As String End Class </code></pre> <p>The code that creates the stream and then writes to it.</p> <pre><code>Dim asfhTemp As List(Of AssetSearchFileHelper) = (From a In lstFilteredAssets Select New AssetSearchFileHelper With { _ .AssetNumber = a.AssetNumber, _ .AssetDescription = a.AssetDescription, _ .SerialNumber = a.SerialNumber, _ .ClassName = a.ClassName, _ .ManufacturerName = a.ManufacturerName, _ .ModelName = a.ModelName, _ .LocationName = a.LocationName, _ .AssignedTo = a.UserFullName}).ToList() Dim dle As New DelimitedFileEngine(GetType(AssetSearchFileHelper)) Dim mStream As New MemoryStream dle.HeaderText = """Asset #"",""Type"",""Serial #"",""Class"",""Make"",""Model"",""Location"",""Assigned To""" Dim sw As New StreamWriter(mStream) dle.WriteStream(sw, asfhTemp) mStream.Position = 0 </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload