I am using SPmetal to read through multiple lists.
I am using Linq to retrieve list items, one of the column is lookup from other list. How to retrieve the lookup column using l
Technology Tips and News
I am using SPmetal to read through multiple lists.
I am using Linq to retrieve list items, one of the column is lookup from other list. How to retrieve the lookup column using l
Hi,
If we consider this example as your query:
var LinqExample = (from testData in LINQObject.ListName
where testData.ColumnName!= null
select testData).FirstOrDefault();
you can get your Lookup column data like this:
if (LinqExample!= null) { string LookupData = LinqExample.LookupColumnNameDestList.LookupColumnNameSourceList.ToString(); }
you can also get similar example here:
https://msdn.microsoft.com/en-us/library/ff798478.aspx?f=255&MSPPError=-2147217396
Hi,
As per my understanding, you are trying to get values of multi value lookup column. Check this link:
Example this s the code I have
var myQ = from fList in FirstEtity
select new
{
fList.Title,
fList.Hobby // This Hobby has multiple value. And its a look up column
}
I am unable to get the data for "fList.Hobby "
it always throws error.
Example this s the code I have
var myQ = from fList in FirstEtity
select new
{
fList.Title,
fList.Hobby // This Hobby has multiple value. And its a look up column
}
I am unable to get the data for "fList.Hobby "
it always throws error.
Error "The query uses unsupported elements, such as references to more than one list, or the projection of a complete entity by using EntityRef/EntitySet."
Found the solution the following code helps
var myQ = from fList in FirstEtity select new { fList.Title, //fList.Hobby // This Hobby has multiple value. And its a look up column Hobby = (from aHobby in fList.Hobby.AsEnumerable() select new { aHobby.Title }), }