LINQ query returning cast exception

Lotok

Well-known member
Joined
Jan 17, 2012
Messages
198
Location
Scotland
Programming Experience
5-10
I am learning linq, up to this point its been going well but cant figure this one out! Using LINQ to query a sharepoint list, done it 100 times by this point but never had this problem before.

Specified cast is not valid.SPAuthSnrMgmtChangesWP at Set__wrkflwCreateID(Object , Object ) at Microsoft.SharePoint.Linq.StaticPropertyMap.SetToEntity(Object entity, Object value) at Microsoft.SharePoint.Linq.SPItemMappingInfo.MaterializeEntity[TEntity](DataContext dc, SPDataList list, SPListItem item, SPItemMappingInfo itemMappingInfo, JoinPath joinPath) at lambda_method(ExecutionScope , SPListItem ) at System.Linq.Enumerable.<>c__DisplayClass12`3.b__11(TSource x) at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext() at SPAuthSnrMgmtChangesWP.ActionChangeRequestUserControl.gvAuth_RowCommand(Object sender, GridViewCommandEventArgs e)

[XCODE]
PrivateSub gvAuth_RowCommand(ByVal sender AsObject, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles gvAuth.RowCommand
Using
ctx AsSPlistsDataContext = NewSPlistsDataContext(pURL)
If e.CommandName = "ActionSubmit"Then
Dim s AsString = CType(e.CommandArgument, String)
Try
Dim results = From c In ctx.EAChangeList Where c.ChangeID = s _
Select c

ForEach item In results
item.ChangeApproverDate =
Date.Today
item.ChangeApproverApproved =
"Approved"

Next

Catch ex AsException
lblMsg.Text = lblMsg.Text & ex.Message & ex.Source & vbCr & ex.StackTrace.ToString
EndTry
ctx.SubmitChanges()
EndIf
EndUsing

EndSub
[/XCODE]

Quick Update:

It actually seem to be the query itself causing the problem
Dim results = From c In ctx.EAChangeList Where c.ChangeID = s _
Select c

 
Last edited:
Back
Top