Hi
I have following entities
A_Entity
-----------
AId
AB_Entity
-----------
AId
BId
B_Entity
-----------
BId
I have a function that helps in building the query based on the input provided. In this case I have to build a query to fetch all A_Entities that have matching BId (provided as input to the function)
public static IQueryabl...
Lets say I have a set of bags. Each bag contains a set of marbles. I would like to select the bags which contain a specific combination of marbles. What is the most efficient way to do this in linq?
In code:
public enum Marble { Red, Green, Blue}
public class Bag {
public string Name;
public List<Marble> contents;
}
var mar...
I have a dictionary of type Dictionary<int, double> and want to eliminate values equal to a certain value.
At the moment I have
Dictionary <int, double> dict = GetDictionary();
dict = dict.Where(x => x.Value != 100).Select(x => x);
And am getting the error:
Cannot implicitly convert type 'System.Collections.Generic.IEnumerable<Syste...
I have a datatable like this:
MtoM
{
ParentID,
ChildID
}
Item
{
ID,
Data,
Label
}
How do I write a linq query that returns every ChildID under a given ParentID and the associated Data and Label for each of these decendent IDs. If I were using SQL I'd use a union all and inner join, but I don't know linq well enoug...
I am trying to implement outer join on this kind of query for p.Person table.
How to do it.
this eg is taken from http://ashishware.com/DSLinqExample.shtml
var onlyinfo = p.Person.Where(n=>n.FirstName.Contains('a')).Join(p.PersonInfo,
n => n.PersonId,
...
This code is returning me a list that I am trying to pass to another function.
_ucItem.lblItemName.Text = itemRow.Field<string>("ITEM_NAME").ToString();
_ucItem.pbxItemImg.Image = itemRow.Field<string>("IMAGE").ToString();
_ucItem.lblItemName.Text = itemRow.Field<string>("FK_ITEM_ID").ToString();
Here I want to replace this set of lin...
I am using multiple joins in a statement and Have tried to make linq-to-SQl query for this but no success.
SELECT ur.UserName, ur.LandmarkRef, lt.Date, l.Place
FROM
tbl_Users ur
LEFT OUTER JOIN tbl_LandMarks l ON ur.LandmarkRef = l.LandMarkID
INNER JOIN tbl_LandmarkTypes lt ON l.LandmarkTypeRef equals lt.LandmarkTypeID
...
Hi there,
i wish to create a repository pattern but with a WCF Rest Service which controls the data access. Can anyone confirm or help with my thinking / config.
ASP.NET Controllers call to service (not rest service but service of a repository pattern)
Repository Pattern Service >> calls to repository
Repository >> calls to WCF Rest S...
Hello,
i try to convert this kind of sql query into linq in visual basic,
but i get stuck on how to make a percent.. I also don't know how to use linqpad for creating this linq
Please help.
SELECT CASE RIGHT(PICName, 3)
WHEN '(P)' THEN 'Problem'
WHEN '(R)' THEN 'Request'
ELSE 'Other'
END AS [Reque...
I have a table like this:
Item
{
int ItemID
int ParentID
string Name
}
Item is actually a subset of a larger table Object:
Object
{
int ObjectID
string Color
}
So ItemID is an FK to ObjectID. Within Item, ParentID can either refer to another Item or to the parent Object.
What I'd like to do is be able to iterate...
I have been stumped on this one for a while. I want to take a List and order the list such that the Products with the largest Price end up in the middle of the list. And I also want to do the opposite, i.e. make sure that the items with the largest price end up on the outer boundaries of the list.
Imagine a data structure like this.. ...
I'm building an expression tree dependency analyzer for a cross data source IQueryProvider.
That is, I have an IQueryable with some elements that can be executed locally in memory against some arbitrary provider (say Entity Framework). Some other elements in the IQueryable go against an entity that I need to make a remote WCF call. The ...
Hi all,
Just a bit rusty on the old linq.
If I have 2 collections EG NewCustomerList and OldCustomerList and see if a surname exists already how would I do it in linq .I am sure there are many ways. SelectMany rings a bell but forgot how to do it!
In a forEach I would do something like that. What is the equivalent in linq?
foreach...
I'm trying to implement Tasks im my Application.
Here's a sample code:
There's one simple Interface I, 3 classes are derived form it (A,B,C)
I create a list of Is, poplualte it with A, B, C instances, and then create a tasf for each other to call method do1();
interface I
{
void do1();
}
class A : I
{
...
Is there any way to write linq statements while project is running?
...
What was the rationale behind renaming of higher order list operations in C#? (Examples: map -> Select, filter -> Where, fold -> Aggregate)
...
Hello everyone.
In the program I'm currently working on, my table has a Create_Timestamp column, which I defined as timestamp.
When I'm working with my data context and my form values in my controller on the HttpPost, I'm trying the following:
NewsArticle article = new NewsArticle();
article.Create_Timestamp = System.DateTime.Now;
T...
How to achieve Oraclel's CONNECT BY PRIOR output using LINQ? Basically i need the hierarchy and level using LINQ?
...
Tables:
Item
Id
Keyword
Id
Keyword
ItemKeyword
ItemId
KeywordId
SequenceNumber
for searching items via keyword:
Keyword keyword = Keyword.FirstOrDefault(a => a.Keyword
.Equals(input, StringComparison.InvariantCultureIgnoreCase));
IEnumerable<Item> items = keyword.ItemKeyword.OrderBy(a => a.SequenceNumber)
.SelectMany(a => a...
I want to check that an IEnumerable contains exactly one element. This snippet does work:
bool hasOneElement = seq.Count() == 1
However it's not very efficient, as Count() will enumerate the entire list. Obviously, knowing a list is empty or contains more than 1 element means it's not empty. Is there an extension method that has this ...