.Contains supported?
.Contains supported?
When we attempt to use Collection.Contains in EF we get an error that this is not supported by the store. Currently we using version 5.00 of dotConnect.
example:
string[] list=new string[]{"test","test2"};
IQueryableresult = from p in Context.ITEM
where list.Contains(p.NAME)
select p;
Above snippet is not the exact example since i'm at home right now..
The desired effect is that above code will be executed as an ORACLE IN statement.
Please let me know what is the wat to go
example:
string[] list=new string[]{"test","test2"};
IQueryableresult = from p in Context.ITEM
where list.Contains(p.NAME)
select p;
Above snippet is not the exact example since i'm at home right now..
The desired effect is that above code will be executed as an ORACLE IN statement.
Please let me know what is the wat to go
There is a workaround, but it's not optimal though.
You can write an exspression that can in some implement the functionality of the Contains method yourself, like following:
and then execute query like this:
This code is for the Dept table, hope it helps.
You can write an exspression that can in some implement the functionality of the Contains method yourself, like following:
Code: Select all
List list = new List{ "RESEARCH", "ACCOUNTING", "test"};
ParameterExpression d = Expression.Parameter(typeof(DEPT), "d");
MemberExpression dname = Expression.PropertyOrField(d, "DNAME");
ConstantExpression listMember;
BinaryExpression compare;
BinaryExpression or = null;
foreach (string s in list) {
listMember = Expression.Constant(s, typeof(string));
compare = Expression.Equal(dname, listMember);
if (or == null)
or = compare;
else
or = BinaryExpression.Or(or, compare);
}
Expression> lambda = Expression.Lambda>(or, d);
Code: Select all
var result = db.DEPT.Where(lambda);
How can one use LINQ to Oracle? I always "Add ADO.NET Entity Data Model" and then use LINQ to the generated Entity classes. Does it mean that I am using LINQ to Entities? Can you give an example please?AndreyR wrote:Unfortunately, we are not aware of any way to use .Contains() with LINQ to Entities.
As an alternative, you can try LINQ to Oracle. I managed to execute the previous code without changes using LINQ to Oracle.
You can read about both LINQ to Entities and LINQ to SQL (LINQ to Oracle is Oracle-specific implementation of LINQ to SQL) here:
http://msdn.microsoft.com/en-us/library/cc161164.aspx
When adding ADO.NET Entity Data Model you will always use LINQ to Entities.
But you can use Devart Entity Developer for generating a .dbml model and using LINQ to generated classes.
http://msdn.microsoft.com/en-us/library/cc161164.aspx
When adding ADO.NET Entity Data Model you will always use LINQ to Entities.
But you can use Devart Entity Developer for generating a .dbml model and using LINQ to generated classes.
MSDN has a generic way of solving this
There is a post on MSDN for a generic method that can be reused for Contains - http://social.msdn.microsoft.com/forums ... 4a1ab59f0/
________
LIST OF TRANSMISSIONS
________
LIST OF TRANSMISSIONS