passing dynamic linq where clause string

passing dynamic linq where clause string

Old forum URL: forums.lhotka.net/forums/t/6335.aspx


dmeadowcroft posted on Wednesday, February 04, 2009

given my fetch method as follows

#region Data Access - Fetch List

[Transactional(TransactionalTypes.TransactionScope)]

private void DataPortal_Fetch(string filter)

{

bool cancel = false;

OnBLUserEndorsementEmailsFetching(ref cancel);

if (cancel) return;

using (var mgr = ContextManager<Pinsoft.Net.DalLinq.PinsoftDataContext>

.GetManager(Globals.PinsoftConnectionString,false))

{

RaiseListChangedEvents = false;

if (filter == "")

{

this.AddRange(

from row in mgr.DataContext.UserEndorsementEmail

select BLUserEndorsementEmail.GetBLUserEndorsementEmail(row)

);

}

else

{

this.AddRange(

from row in mgr.DataContext.UserEndorsementEmail

.Where(filter)

select BLUserEndorsementEmail.GetBLUserEndorsementEmail(row)

);

}

RaiseListChangedEvents = true;

}//using

 

OnBLUserEndorsementEmailsFetched();

}

I am trying to pass the following string as the filter..

"PolicyID = new Guid(\"b5e7a7e0-4e38-4da1-bb6b-9b7a00b0f9c1\")"

but it failing with - "'(' expected"

from what I can see in studying the info on the web for dynamic linq, this should work ..

anyone know what I might be doing wrong?

thanks in advance..

 

simon replied on Monday, June 29, 2009

I have same problem.  in the wish list  about dynamic linq 300 days ago is still open.

RockfordLhotka replied on Monday, June 29, 2009

This is not, from what I can see, a CSLA issue. This is about constructing dynamic LINQ queries using LINQ to SQL.

Copyright (c) Marimer LLC