Hi There,
I've tried many different ways of doing this, using this code inside my user control works just fine:
Dim qAssets = (From A In DataAccess.LinqMetaData.AssetTradingControl _
Join AA In DataAccess.LinqMetaData.Assets On A.AssetId Equals AA.AssetId _
Join I In DataAccess.LinqMetaData.InvestingFunds On A.Ifid Equals I.Fund _
Join TT In DataAccess.LinqMetaData.AssetTranTypes On A.TransTypeId Equals TT.TranTypeId
Select
A.RecordId,
A.AssetId,
AA.AssetDesc,
A.Ifid,
Fund = If(I.Fund.Equals(Nothing), "All Funds", I.[Description]),
TransactionType = If(TT.TranTypeId.Equals(Nothing), "All Transaction Types", TT.TranTypeDesc),
LastTradingDate = If(A.LastTradingDate.Equals(Nothing), SQL_LOWDATE, A.LastTradingDate),
NextTradingDate = If(A.NextTradingDate.Equals(Nothing), SQL_HIGHDATE, A.NextTradingDate),
ControlStatus = If(If(A.NextTradingDate.Equals(Nothing), SQL_HIGHDATE, A.NextTradingDate) <= DateTime.Now.Date, "Expired", "Active"),
A.CreationDate,
A.CreatedBy,
A.LastModifiedDate,
A.LastModifiedBy
Order By AssetId, NextTradingDate).AsQueryable
e.QueryableSource = qAssets.Where(Function(x) x.RecordId > 160).AsQueryable()
e.QueryableSource = qAssets.Where(Function(x) x.AssetId = 11).AsQueryable()
However the idea is that the query will be passed in from whatever form is using the control.
So in the form I have this code:
Dim qAssets = From A In DataAccess.LinqMetaData.AssetTradingControl _
Join AA In DataAccess.LinqMetaData.Assets On A.AssetId Equals AA.AssetId _
Join I In DataAccess.LinqMetaData.InvestingFunds On A.Ifid Equals I.Fund _
Join TT In DataAccess.LinqMetaData.AssetTranTypes On A.TransTypeId Equals TT.TranTypeId
Select
A.RecordId,
A.AssetId,
AA.AssetDesc,
A.Ifid,
Fund = If(I.Fund.Equals(Nothing), "All Funds", I.[Description]),
TransactionType = If(TT.TranTypeId.Equals(Nothing), "All Transaction Types", TT.TranTypeDesc),
LastTradingDate = If(A.LastTradingDate.Equals(Nothing), SQL_LOWDATE, A.LastTradingDate),
NextTradingDate = If(A.NextTradingDate.Equals(Nothing), SQL_HIGHDATE, A.NextTradingDate),
ControlStatus = If(If(A.NextTradingDate.Equals(Nothing), SQL_HIGHDATE, A.NextTradingDate) <= DateTime.Now.Date, "Expired", "Active"),
A.CreationDate,
A.CreatedBy,
A.LastModifiedDate,
A.LastModifiedBy
Order By AssetId, NextTradingDate
XFilterActionGrid1.qAssets = qAssets
and in the user control I have this:
#Region "Properties and variables"
Public qAssets
#End Region
#Region "Methods"
Private Sub LinqInstantFeedbackSource1_GetQueryable(ByVal sender As Object, ByVal e As DevExpress.Data.Linq.GetQueryableEventArgs) Handles LinqInstantFeedbackSource1.GetQueryable
e.QueryableSource = qAssets.Where(Function(x) x.RecordId > 160).AsQueryable()
e.QueryableSource = qAssets.Where(Function(x) x.AssetId = 11).AsQueryable()
End Sub
and I get this error:
Public member 'Where' on type 'LLBLGenProQuery(Of VB$AnonymousType_39(Of Integer,Integer,String,Nullable(Of Integer),String,String,Nullable(Of Date),Nullable(Of Date),String,Nullable(Of Date),String,Nullable(Of Date),String))' not found.
Can you show me an example where a form can pass the query to a usercontrol and have it work?
regards
Kevin