I am trying accomplish the LINQ query below but I need a "not equal" instead of equal, so that filteredEmployees has all employees from groupA minus groupB.
List<Employee> groupA = getEmployeeA();
List<Employee> groupB = getEmployeeB();
var filteredEmployees = from a in groupA
join b in groupB on a.Nam...
I'm working on a project that will combine a couple of sharepoint listitemcollections. It's basically to bring together three sharepoint lists.
I've already gotten my three sharepoint queries to return my proper results and im using the .GetDataTable() method to generate my objects for LINQ joins.
Below is my code. I may be approachi...
If txtSearchString.Text.Trim <> "" Then
Dim searchString As String = txtSearchString.Text.Trim
Dim results As EnumerableRowCollection(Of DataRow) = From PO In FilterPurchaseOrders().AsEnumerable() _
Where PO("Title") Like searchString Or PO("PONumber") Like searchString _
Or PO(...
I have a List of X items. I want to have LINQ query that will convert it into batches (a List of Lists), where each batch has 4 items, except for the last one which can have 1-4 (whatever the remainder is). Also, the number 4 should be configurable so it could 5, 17, etc.
Can anyone tell me how to write that?
List<Item> myItems = ......
Given the following code :
var EmployeeXPosition = from emp in context.WTDEmployee
from ep in emp.WTDEmployeeXOXPosition
select new {
EmployeeId = emp.id,
FullNameAndPosition = string.Format(...
I have about 10 calls that have the same select statement. It's more than a simple FirstOrDefault, it has some db logic inside of it. I have not seen a good way to extract this into its own method or statement. I have come close with something like this:
static readonly Expression<Func<DbUser, User>> GetUser = (g) => new User {
Ui...
I had the following statement, which always returns null:
var addins = allocations.SelectMany(
set => set.locations.Any(q => q.IsMatch(level, count))
? (List<string>)set.addins : null
);
I changed it slightly, and now it works fine:
var addins = allocations.SelectMany(
set => set.locations.Any(q => q.IsMa...
public class ReplacementService : IReplacementService
{
public List<int> GetTeamReplacementWeight(int iTeamId)
{
IEnumerable<TeamReplacementGroup> groups = TeamReplacementGroup.GetTeamGroups(iTeamId);
List<int> weights= groups
.Select(group => group.GetWeight())
.AsParallel()
.T...
Hello, I have a DataTable. I can also use Linq.
In a DataTable have many columns, and rows. One of the column is called as feedCode. its type is string. in database it's length is 7 varchar, nullable.
feedCode may contain values as 9051245, 9051246, 9051247, 9031454, 9021447.
Method must return most matched (in this case starting with...
Hello,
I've created a View in the database that gives me a representation of an organisation structure AT THIS POINT IN TIME. Indeed, I use a getdate() in this view. I've imported the view in my edmx and wrote queries based on this view. Most queries join a table with the view and return a DTO. These queries work fine and are fast (200m...
I'm reading manning book about LINQ, and there is an example:
static class QueryReuse
{
static double Square(double n)
{
Console.WriteLine("Computing Square("+n+")...");
return Math.Pow(n, 2);
}
public static void Main()
{
int[] numbers = {1, 2, 3};
var query...
How to read file name with dll extension from a directory and from its subfolders recursively using LINQ or LAMBDA expression.
Now i'm using Nested for-each loop to do this.
Is there any way to do this using LINQ or LAMBDA expression?
...
I got a scenario where we are doing soft delete on the rows in database. I want to include the rows that are not deleted. How can I achieve it using LINQ.
Say
from c in context.ASDSet
where (c => c.DeletedFlag.HasValue && !c.DeletedFlag.Value)
But I couldn't achieve the result.
I want the resultant SQL to be of form:
select * from...
This has confused me, I have the title error on the join in the following LINQ:
var r = (from k in location.tblKeyAccountInfoes
join l in location.tblLocations
on new { k.MemberID, k.LocationID } equals
new {l.MemberId, l.LocationId }
where k.MemberID ==...
I've got a 2.0 server control that uses a dynamic query roughly in the form:
string sql = "Select " + columnvariable + " FROM " + tablenamevariable
So, obviously, you could give it any valid column name from any valid table in the DB and it would return the values in the column into a DataReader (in this case).
I'm trying to cut down...
I'm working with ASP.NET 3.5 SP1 and I have a question that I've been stuck on.
I have an ASPX page on which I have 2 repeater controls, 1 nested inside the other.
From the code behind I have a simple LINQ To Entities query which retrieves the data and I then bind this data to the repeater controls.
The ASPX page is shown below:
<asp:Re...
I've had been told that since .net linq is so slow we shouldn't use it and was wondering anyone else has come up with the same conclusion, and example is:
Took 1443ms to do 1000000000 compares non-LINQ.
Took 4944ms to do 1000000000 compares with LINQ.
(243% slower)
the non-LINQ code:
for (int i = 0; i < 10000; i++)
{
foreach (MyLi...
I have a "manager" class with a number of sub-classes. I find one particular method being duplicated in all or almost all of the sub-classes, so I want to generalize it. In one case, it looks like this:
var Results =
from j in Job.All( )
where guids.Contains( j.Job...
I am using a LINQ to SharePoint query to return items from a SharePoint list.
var myOpenTasksQuery = from myTasks in tasks
where myTasks.TaskStatus != TaskStatus.Completed
select myTasks
However, the list I am querying, an OOTB Tasks list, there are a number of multi-choice fields (Status,...
I'm using Linq to try to filter out any duplicate XElements that have the same value for the "name" attribute.
Original xml:
<foo>
<property name="John" value="Doe" id="1" />
<property name="Paul" value="Lee" id="1" />
<property name="Ken" value="Flow" id="1" />
<property name="Jane" value="Horace" id="1" />
<property name="Paul" value...