I've got a list of lists which I want to intersect:
List<List<int>> input = new List<List<int>>();
input.Add(new List<int>() { 1, 2, 4, 5, 8 });
input.Add(new List<int>() { 3, 4, 5 });
input.Add(new List<int>() { 1, 4, 5, 6 });
Output should be
{ 4, 5 }
How can this be accomplished in a terse fashion?
...
hay all.
i am trying to transform html to xml
meaning extracting all elements with text
using this code is not working maybe some one has the answer ?
System.Xml.Linq.XElement query1 = new System.Xml.Linq.XElement("RawHTMLData",
from q in hDoc.Descendants("TABLE")
where q.HasElements
select new System.X...
hi, i've got a problem with dataset:
I've got two dataset from two different server but they have the same columns.
so it's like that:
First DataSet :
asset description make jobtype jan feb ... dec
0001 mine ik Acc 0 0 10
0002 yours ic Over 0 0 10
Second dataset :
asset description make ...
I have the following class:
public class Item
{
public Dictionary<string, string> Data
{
get;
set;
}
}
and a list of it:
List<Item> items;
I need to filter and order this list dynamically using SQL-Like strings. The catch is, that I need to order it by the Data dictionary.
For example: Order By Data["l...
How can I do a multi-level parent-child sort using Linq if I have a table structure like the one below:
[Table: Sections]
Id Seq Name ParentSectionId
1 1 TOP NULL
2 1 AAAA 1
3 2 SSSS 1
4 3 DDDD 1
5 1 SectionA1 2
6 2 SectionA2 2
7 1 ...
How do I get all of the "columns" using linq from this dictionary.
Dictionary<int, Dictionary<int, string>> _cells;
where I can access a row this way
var someRow = _cells[2];
and I am able to get a cell
string cell = _cells[2][2];
What I am trying to do is create table.
A | B | C | ...
1 | * | * | * | ...
2 | * | * | * | ....
I have an array of input strings that contains either email addresses or account names in the form of domain\account. I would like to build a List of string that contains only email addresses. If an element in the input array is of the form domain\account, I will perform a lookup in the dictionary. If the key is found in the dictionar...
I've got a LinqDataSource that retrieves a single record.
Protected Sub LinqDataSource1_Selecting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.LinqDataSourceSelectEventArgs) Handles LinqDataSource1.Selecting
Dim BizForSaleDC As New DAL.BizForSaleDataContext
e.Result = BizForSaleDC.bt_BizForSale_GetByID(e.WherePar...
Is there anyway this code can be refactored? The only difference is the order by part.
Idealy I'd like to use a delegate/lamda expression so the code is reusable but I don't know how to conditionally add and remove the query operators OrderBy and OrderByDescending
var linq = new NorthwindDataContext();
var query1 = linq.Custom...
Normally, I do this:
var a = from p in db.Products
where p.ProductType == "Tee Shirt"
group p by p.ProductColor into g
select new Category {
PropertyType = g.Key,
Count = g.Count() }
But I have code like this:
var a = Products
.Where("ProductType == @0", "Tee Shirt")
...
Hi fellow coders
I'm new at LINQ, searching the net for LINQ samples that mimic SQL's LIKE statement doesn't satisfy myself.
What I want is producing the same query result as this SQL
SELECT * FROM table_1 WHERE column_1 LIKE '__0%'
I want to query from table_1 where column_1's third character is '0'
Is there equivalent statement i...
My knowledge of Lambda expressions is a bit shaky, while I can write code that uses Lambda expressions (aka LINQ), I'm trying to write my own method that takes a few arguments that are of type Lambda Expression.
Background: I'm trying to write a method that returns a Tree Collection of objects of type TreeItem from literally ANY other o...
Hello,
I'm new to C# and am stuck on the following. I have a Silverlight web service that uses LINQ to query a ADO.NET entity object. e.g.:
[OperationContract]
public List<Customer> GetData()
{
using (TestEntities ctx = new TestEntities())
{
var data = from rec in ctx.Customer
select rec;
retu...
While trying to use linq in a .NET 2.0 winforms project I got:
Namespace or type specified in the Imports 'System.Linq' doesn't contain any public member or cannot be found. Make sure the namespace or the type is defined and contains at least one public member. Make sure the imported element name doesn't use any aliases
In both the lin...
I have a collection:
List<Car> cars=new List<Car>
Cars are uniquely identified by CarCode.
I have three cars in the collection, and two with identical CarCodes.
How can I use LINQ to convert this collection to Cars with unique CarCodes?
...
I am having xml with following structure
<ruleDefinition appId="3" customerId = "acf">
<node alias="element1" id="1" name="department">
<node alias="element2" id="101" name="mike" />
<node alias="element2" id="102" name="ricky" />
<node alias="element2" id="103" name="jim" />
</node>
</ruleDefinition>
...
I originally created a process that occurred by transitioning between views in a multiview and it worked fine. Now, I've moved this same code into a ASP.NET Wizard and it keeps throwing an error at the second step. The error is:
Method 'System.Object AndObject(System.Object, System.Object)' has no supported translation to SQL.
Any ideas ...
I'm writing a simple program that will run entirely client-side. (Desktop programming? do people still do that?) and I need a simple way to store trivial amounts of data in a structured form, but really don't see any need to use a database system. What's more, some of the data needs to be serialized and passed around to different users,...
Say I have an User (mapped to a User table) and the Edit view (in MVC) displays a multiselectlist of Modules (mapped to a Modules table) that user can access, with the Modules pre-selected based on the User's EntitySet of Modules.
I have tried saving the User then deleting all User_Modules manually and adding them back based on what's s...
If I have a query like this:
String Category = HttpContext.Current.Request.QueryString["Product"].ToString();
IQueryable<ItemFile> pressReleases = from file in connection.ItemFile
where file.Type_ID == 8
&& file.Ca...