Issue with LINQ query to run on datatable in VB.NET on Framework 4.0 - PLZ HELP

Posted by Anbu210 under VB.NET on 8/2/2012 | Points: 10 | Views : 1873 | Status : [Member] | Replies : 0
I have 25000+ records with 30+ columns in a datatable name MOU_SAS_VIEW_Table.
I need to run below query in the code and save it in a new datatable.

select SAS_ID, BAN, BILL_SEQ_NO, SUBSCRIBER_NO, USG_CAT_DESC_ENG, UNIT_OF_MEASURE, SOC, POOLING_GRP_ID,
SHARING_GROUP_ID, USED_UNITS, ADDITIONAL_USED, INC_UNITS_ENG,
IIf([NEGATIVE_AMT_IND]='Y',(-1*OVG_AMOUNT_ENG),(OVG_AMOUNT_ENG)) AS OVG_AMOUNT_ENG
from MOU_SAS_VIEW_TABLE WHERE ((SUBSCRIBER_NO)<>'0000000000')
ORDER BY DISPLAY_ORDER, USG_CATEGORY_CODE, USG_CAT_GRP_CODE

In the FROM part mou_sas_view_table is a datatable. Table not available in Access database.

So I used LINQ to run the query on datatable
Like :

MOU_SAS_VIEW_Table.TableName = "SAS_VIEW"
Dim tempSAS As DataTable = MOU_SAS_VIEW_Table

Dim Query = From SAS_VIEW In tempSAS.AsEnumerable _
Where SAS_VIEW.Field(Of String)("SUBSCRIBER_NO") <> "0000000000" _
Order By ("DISPLAY_ORDER"), ("USG_CATEGORY_CODE"),("USG_CAT_GRP_CODE") _
Select New With _
{ _
.SAS_ID = SAS_VIEW.Field(Of Long)("SAS_ID"), _
.BAN = SAS_VIEW.Field(Of Long)("BAN"), _
.BILL_SEQ_NO = SAS_VIEW.Field(Of Long)("BILL_SEQ_NO"), _
.SUBSCRIBER_NO = SAS_VIEW.Field(Of String)("SUBSCRIBER_NO"), _
.USG_CAT_DESC_ENG = SAS_VIEW.Field(Of String)("USG_CAT_DESC_ENG"), _
.UNIT_OF_MEASURE = SAS_VIEW.Field(Of String)("UNIT_OF_MEASURE"), _
.SOC = SAS_VIEW.Field(Of String)("SOC"), _
.POOLING_GRP_ID = SAS_VIEW.Field(Of String)("POOLING_GRP_ID"), _
.SHARING_GROUP_ID = SAS_VIEW.Field(Of String)("SHARING_GROUP_ID"), _
.USED_UNITS = SAS_VIEW.Field(Of String)("USED_UNITS"), _
.ADDITIONAL_USED = SAS_VIEW.Field(Of String)("ADDITIONAL_USED"), _
.INC_UNITS_ENG = SAS_VIEW.Field(Of String)("INC_UNITS_ENG"), _
.OVG_AMOUNT_ENG = IIf(SAS_VIEW.Field(Of String)("NEGATIVE_AMT_IND") = "Y", (-1 * SAS_VIEW.Field(Of String)("OVG_AMOUNT_ENG")), SAS_VIEW.Field(Of String)("OVG_AMOUNT_ENG"))
}
Dim table1 As DataTable = Query.CopyToDataTable()

Please note that .OVG_AMOUNT part is in single line..

I got error as below.. at Query.CopyToDataTable()
MissingMemberException was unhandled
Public member 'CopyToDataTable' on type 'EnumerableRowCollection(Of VB$AnonymousType_0(Of Long,Long,Long,String,String,String,String,String,String,String,String,String,Object))' not found.

Plz help me to fix this issue

Anbu


Responses

(No response found.)

Login to post response