Can anyone explain to me why xml1.Element("title") correctly equals "<title>Customers Main333</title>" but xml2.Element("title") surprisingly equals null, i.e. why do I have to get the XML document as an element instead of a document in order to pull elements out of it?
var xml1 = XElement.Load(@"C:\\test\\smartForm-customersMain.xml")...
I have a class (ClassA) that has a IEnumerable property. I then has another class (ClassB) that has the same property. They are sharing an interface (InterfaceA). The ClassB is basically a container class for multiple ClassA's. How to I implement the property for ClassB.
interface InterfaceA
{
IEnumerable<int> MyInts
{
...
Linq-To-Sql enables calling SPs. If this SP executes an update/delete/insert, do I need to SubmitChanges() after it?
...
We've found that compiling our Linq queries is much, much faster than them having to compile each time, so we would like to start using compiled queries. The problem is that it makes code harder to read, because the actual syntax of the query is off in some other file, away from where it's being used.
It occurred to me that it might be ...
I have an entity that has a 1-to-many relationship with another ( Entity Position has One Department).
In the details view I'm showing in s combobox a list of all the departments available and I want to start the selecteditem in the combo is the department to which the entity is related.
The problem is than I am using layers so the Pos...
I have a query which returns data for a number of dataseries in one lump.
I would like to split this data up into the data series id, by the dataseries id. The query cannot be changed.
Its not safe to assume that the data is ordered by the series id, so what would be the best way to do this? LINQ?
...
Hi,
I am using Linq to dataset to query a datatable. If i want to perform a group by on "Column1" on data table, I use following query
var groupQuery = from table in MyTable.AsEnumerable()
group table by table["Column1"] into groupedTable
select new
{
x = groupedTable.Key,
y = groupedTable.Count()
}
Now I want to perform group...
I am trying to do a like comparison based on an outside parameter (passed by a search form) that determines type of comparison ("%string" or "string%" or "%string%")
I was thinking in the following direction:
query = query.Where(
Entity.StringProperty.Like("SearchString", SelectedComparsionType)
)
Like method would than based on sel...
Hi!
I need to filter the child elements of an entity in linq using a single linq query. Is this possible?
Suppose I have two related tables. Verses and VerseTranslations. The entity created by LINQ to SQL is such that i have a Verse object that contains a child object that is a collection of VerseTranslation.
Now if i have the follow...
I have a class Booking
public class Booking
{
public int Id { get; set; }
public string From { get; set; }
public string To { get; set; }
}
I create a List bookings with the help of linq and I want some mechanism with which I want to autogenerate the 'Id' property to increment by 1.
I.e. if the List ...
say I've got a DataTable in this format:
id | key1 | key2 | data1 | data2 | parentID
10 | AA | one | 10.3 | 0.3 | -1
10 | AA | two | 20.1 | 16.2 | -1
10 | BB | one | -5.9 | 30.1 | -1
20 | AA | one | 403.1 | -20.4 | 10
30 | AA | one | 121.5 | 210.3 | -1
and a second DataTable like so:
id | data
10 | 5500
20...
Hi,
how do I cast and int into a string? None of the following do works:
from s in ctx.Services
where s.Code.ToString().StartsWith("1")
select s
from s in ctx.Services
where Convert.ToString(s.Code).StartsWith("1")
select s
from s in ctx.Services
where ((string)s.Code).ToString().StartsWith("1")
select s
EDI...
How can I make the following SQL a Linq query:
SELECT * FROM ORDERS
INNER JOIN ITEMS
ON ORDERS.ID = ITEMS.ORDER_A OR ORDERS.ID = ITEMS.ORDER_B
I would think it would be:
from o in orders
join i in items
on o.ID equals i.OrderA or o.ID equals i.OrderB
select new { Order = o, Item = i }
I'm guessing the compiler wants something else....
What exactly is happening behind the scenes in a LINQ query against an object collection? Is it just syntactical sugar or is there something else happening making it more of an efficient query?
...
I have a List of objects which contain a string array as one of their properties. I want to get a distinct string array containing all the values.
My object looks like this:
public class Zoo {
string Name { get; set;}
string[] Animals { get; set;}
}
Some zoos may have only one animal, some may have many. What would be the sim...
Imports System.Xml.Linq
Imports System.Linq
Partial Class test2
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim xml As XElement = <book>
<title>My Title</title>
<author>Kyle</a...
In a project I am working on, there are really huge collections (1M-1B elements), and things are modified as collections mostly.
It's a real-time app, and so the performance is paramount.
For some of the operations, like Reverse, BinarySearch (possible?), etc will suffer more than others like Select, etc.
Is it feasible to implement o...
I found in MSDN's Linq samples a neat method called Fold() that I want to use. Their example:
double[] doubles = { 1.7, 2.3, 1.9, 4.1, 2.9 };
double product =
doubles.Fold((runningProduct, nextFactor) => runningProduct * nextFactor);
Unfortunately, I can't get this to compile, either in their example or in my own code, and I c...
Hi,
I am still visiting school and will finish my exams next year. Since two years I am working as (the only :-( ) in-house dev for a company providing financial services to Laboratories and doctors. After spending the first year fixing their existing Application and realizing, communicating and agreeing that it won't meet future requi...
Hi guys...
How should I use this in .NET 2.0 ...?
[DataObjectMethod(DataObjectMethodType.Select)]
public IEnumerable<OperatorField> FindByType(String type)
{
// return only selected type
return (from ce in this.OperatorFields where ce.Type == type select ce).ToList();
}
I use this in a 3.5 projects, but now I'm adding new fu...