Code: Select all
Dictionary> Lookup = new Dictionary>();
//Used in my commented out Linq Query
List Status = new List() { 0, 1, 2, 4 };
Lookup.Add(200, new List() { 0, 1, 2 });
Lookup.Add(330, new List() { 0, 1, 4 });
using (Entities ent = new Entities())
{
try
{
//var result = from d in ent.TM_FNET
// where Lookup.Keys.Contains(d.ACTION.Value)
// && Status.Contains(d.STATUS.Value)
// select d;
var result = from d in ent.TM_FNET
where Lookup.Keys.Contains(d.ACTION.Value)
&& Lookup[d.ACTION.Value].Contains(d.STATUS.Value)
select d;
foreach (var f in result)
{
Console.WriteLine("{0} -- {1} -- {2}", f.ACTION, f.ID, f.STATUS);
}
Console.WriteLine("Finished");
Console.ReadKey();
}
catch
{
}
}
What I'm expecting is linq to translate the query into something like the following:LINQ to Entities does not recognize the method 'System.Collections.Generic.List`1[System.Decimal] get_Item(System.Decimal)' method, and this method cannot be translated into a store expression.
Code: Select all
SELECT
*
FROM
tm_fnet
WHERE
(ACTION = 200 AND STATUS IN (0,1,2))
OR
(ACTION = 330 AND STATUS IN (0,1,4));
Thanks!