I'm new to LINQ so apologies if this is a simple answer. I'm trying to do a SQL join and have the following code based on examples I've seen on SO and elsewhere:
var query = from e in db.Events
join ec in db.EventCategories on e.ID equals ec.EventID
join c in db.Categories on ec.CategoryCode equals c.CategoryCode
join ep in ...
I need to write some .NET code for listing user and groups. I am planing to use LINQ. I do not have access to the Active directory for testing. I do not have a server and can not set up my own Active directory. Are there any public Active directory that I could use for testing. The code is only reading data from the Active directory and ...
Ok, I'm trying to get this working. This is my first time using LINQ. So far it's ok except a little snag that I've been trying to figure out.
Scenario: I have 2 generic lists I'm sending to a method. That method has this in it below to give me back a list of only those objects (union) where a certain ID is found in both. The lis...
I'm looking for this list for Entity Framework. Ideally, I'd like to have a list of other supported methods (or members - e.g. constructors), e.g. for DateTime type.
...
Hi, is there a way of knowing ID of identity column of record inserted via InsertOnSubmit beforehand, e.g. before calling datasource's SubmitChanges?
Imagine I'm populating some kind of hierarchy in the database, but I wouldn't want to submit changes on each recursive call of each child node (e.g. if I had Directories table and Files ta...
I'm looking for such list for LINQ to SQL. Ideally, I'd like to have a list of other supported methods (or members - e.g. constructors), e.g. for DateTime type.
...
When using ria service for SL app, I can issue following async call to get a group of entity list.
LoadOperation<Person> ch =
this.AMSContext.Load(this.AMSContext.GetPersonQuery().Where(a => a.PersonID == this.performer.PersonID));
But I want to get some calculation, for example, sum(Commission), sum(Salary), the result is not entity...
In the Framework we are building we need the following pattern:
public class BaseRenderer
{
Func<string> renderer;
public BaseRenderer(Func<string> renderer)
{
this.renderer = renderer;
}
public string Render()
{
return renderer();
}
}
public class NameRenderer : BaseRenderer
{
public st...
So, I've got a small chunk of stabby, pointy xml that looks like this:
<Groups UseGroup='True'>
<Group>1264,182,1979</Group>
</Groups>
And I've got a small chunk of linq that gets the value from that looks like this:
var group = from a in xml.Descendants("Groups")
select a.Element("Group").Value;
It's all fine and dandy...
I want to select the persons only who are having pets.
when I execute the query
var query = from p in people
join
pts in pets
on p equals pts.Owner into grp
select new {grp=grp,PersonName=p.FirstName};
Person does not have pet also get se...
I have a linq to dataset query that joins two tables and extracts the desired parameters from each. I need to get them into a DataTable to bind to a DataGridView. The example I found for doing this on MSDN is a trivial example taking a single value from a single table, but when I tried to change my query to follow it I was unable to do...
I am getting this error and I have collection of anonymous Datarows and each item contains two datarows. How to cast this?
Unable to cast object of type 'WhereSelectEnumerableIterator`2[VB$AnonymousType_0`2[System.Data.DataRow,System.Data.DataRow],VB$AnonymousType_0`2[System.Data.DataRow,System.Data.DataRow]]' to type 'System.Data.Enume...
I'm using LINQ to SQL in ASP.NET MVC. I wrote some new code to update Orders in our system, and as far as I can tell it's exactly like a hundred other similar pieces of code I've written (grab the object, update some fields, submit changes).
This time though, when I try to run the update, I get a "Row not found or changed" LINQ excepti...
I'm working with the C# membership provider and transferring it to LINQ along the way.
I'm having trouble pulling the results from a stored procedure in MS SQL.
The procedure does some work to set variables and then selects the variables before setting the return value of 0.
When I run this in MS SQL to test it works fine.
When I run i...
i am using sql server 2005 and I think Linq generating queries for a different database version. I got the query string that linq was producing and pasted the linq directly in SQL Server Management studio and it failed with many errors. But the query works well if Linq is used. Any ideas what could be going on. If linq needs to know what...
I have a generic SelectAllByKey method in my repository:
public IList<E> SelectAllByKey(string columnName, string key)
{
KeyProperty = columnName;
Expression rightExpr = null;
rightExpr = Expression.Constant(key);
// First we define the parameter that we are going to use the clause.
var ...
From two sets
var set1 =new int[] { 1, 2, 3 };
var set2 =new int[] { 100, 200, 300 };
How to check index value of elements in set1 and set 2 ? if index value of elements of set1
equals to index value of elements of set2 then i want that pair like
{1,100} ,{2,200},{3,300}.
Some incomplete code
var pairs=from n1 in set1
...
Hi
I have a very annoying problem with LINQ and MS SQL Server.
Im currently making some software in WPF C# and use LINQ to generate classes from the data in the database.
However, when i update a nvarchar or varchar field in the DB from my program, LINQ adds trailing spaces to the string!
I have a field in a table defined like this:
...
For some reason, my call to IEnumerable.Where() using String.StartsWith() appears to be giving different results depending on whether it's being used in LINQ-to-SQL or standard LINQ (-to-objects). If I add in a call to ToList() on what's otherwise the same call, I get different results back:
var withToList = MyDataContext.MyEntities.ToL...
Hi,
How do you use LINQ (C#) to select the value in a particular column for a particular row in a datatable. The equivalent SQL would be:
select NAME from TABLE where ID = 0
Thanks in advance.
...