c# - Convert DataTable to LINQ: Unable to query multiple fields -
Importing a spreadsheet I have filled a datatable object with that data and gets the expected result.
By putting it in a format, I can easily query to search for the following issues.
Public Zero Some (Datatale DT) {var data = in line From dt.AsEnumerable () in the selection row ["command"] ToString () .; }
Works as expected, giving me a list of commands, although I can not add other fields to this field by trying to add other fields as this EnumerableRowCollection I get an error
Public Zero Some (Datatelle DT) {// row ["version"] gives me an error = line from the row = Asenumerable () Selection row ["command "] ToString (), line ["version"]. ToString (); }
Error: "A local variable named in this area can not be declared 'because it will give a different meaning for the' row 'which is already used in the' child 'field Do something else. "
I think I should go by the name of the column, but I have no luck. What am I missing here?
It seems that you are writing a bad selection statement, try the following:
< Pre = select public {N} {datatale dt} {var data = line from dt.AsEnumerable (new). New order {line = "order"]. ToString (), some = row ["something"] ToString (), Customer = Line ["Customer"]. ToString (), address = line ["address"]. ToString ()}; }
This will create a new collection of anonymously typed objects that you can iterate and use as necessary. Keep in mind, however, you want to be able to return to the data function if you need that functionality, then you need to create a solid type to use (instead of anonymized forms) .
Comments
Post a Comment