Is there a way to cast an xml to a string in a Linq query. Something like this, but in LINQ:
select TOP(10) * from PackageSessionNodes
where CAST(Interactions as nvarchar(max)) like '%asset id%'
order by PackageSessionNodeId desc
This doesn't work:
var packageSessionNodes = from psn in db.PackageSessionNodes
...
I have an xml file that is like this:
<xml>I need this text<notthistext>blahblah<notthistext></xml>
I get the text by doing something like this:
var mycollection = from myNode in myDoc.descendents("xml") select new { test = Convert.ToString(myNode.Nodes().First())}
but the problem is that there are carrige returns and spaces that d...
So I have a query that looks something like this:
var clams = from clam in Clams
where clam.ClamTypeID == 143 &&
clam.ParentClamID == null
select clam;
Nothing too crazy, returns the results that I need. But when I have it in a function where I'm passing in the possible null value as a int? I...
I have a collection of Points, stored in a PointCollection.
I need the points in the collection to draw lines.
So, for example, if a point collection has four points, that will be three lines.
Example:
(1) Point(1,1)
(2) Point(2,2)
(3) Point(3,3)
(4) Point(4,4)
If I have a list of points, comprised of the four points referenced abov...
I sometimes do this:
XElement.Descendants("mynodename");
is there a way to do something like this"
XElement.Descendants("mynodename or myothernodename");
...
I have a datatable which I will convert to a list<datarow>. How do I sort the list based on some datatable column? I think it's something like list = list.Sort(p=>p.Field() but I am not sure about the syntax.
I am interested in using LINQ heavily so I was wondering if I should convert the datatable to a strongly typed generic list and t...
I am interested in using LINQ against Excel. Right now I am using oledb to read a sheet into a datatable and then maybe convert it to list and then I want to manipulate the data and write back to Excel. Seems cumbersome.
Is there an easier way using LINQ to do this stuff in a more straightforward way?
...
I'm just getting my feet wet with LINQ. Given three lists of items, this is what I've come up with to only show ClassA items that are referenced in the list of ClassB items but not in the list of ClassC items.
var uniqueClassAIDsInClassB =
(from classB in classBList
select classB.ClassAID).Distinct();
var uniqueClassAIDsInCla...
I was playing around with expression trees and various Linq syntax. I wrote the following:
using (NorthwindDataContext DB = new NorthwindDataContext())
{
DataLoadOptions dlo = new DataLoadOptions();
// Version 1
dlo.AssociateWith<Customer>(c => c.Orders.Where(o => o.OrderID < 10700).Select(o...
I am trying to save an XDcoument to a thumb drive which doesnt have enough memory space available. (This is a special test condition for the app) Though the application is giving an exception like below, I cant get that in the try catch block around the XDocument.Save(filePath). Looks like it is a delayed throw. Is it a LINQ issue or am ...
I have a large list (~ 110,000 strings), which I need to compare to a similar sized list.
List A comes from 1 system.
List B comes from a SQL table (I can only read, no stored procs, etc)
What is the best way to find what values are in list A, that no longer exists in list B?
Is 100,000 strings a large number to be handled in an array...
I need a query that returns subtotals by MemberName(PersonID) but broke out into the 2 different ContactTypes(11 & 12 under IsFaceToFace). The below query gets me the base data I need without any subtotals.
I tried messing around with WITH ROLLUP and PARTITION BY but those are new to me and never worked completely right. I am sure I...
So I am trying to write something like this:
SELECT s.CompanyID,
s.ShareDate,
s.OutstandingShares,
s.ControlBlock
FROM (
SELECT MAX(ShareDate) AS Sharedate,
CompanyID
FROM ShareInfo
WHERE (ShareDate <= @filter_date)
GROUP BY CompanyID
) AS si
INNER JOIN
tblShareInfo AS s ON s....
In episode 77 Joel and Jeff were discussing using links instead of a for loop. I looked in Stack Overflow, Google, and Wikipedia but couldn't find any reference to a links construct. The closest thing I could find was a self referencing linked list which would presumably loop indefinitely. Is links a feature of the Links programming l...
I'm new to LINQ and am having a problem. I have a file that looks something like this:
<?xml version="1.0" encoding="utf-8" ?>
<Galleries>
<Gallery ID="10C31804CEDB42693AADD760C854ABD" Title="Test1">
<Description>The first test gallery. Picture of a cat and Wilford Brimley. Can you tell the difference?</Description>
<I...
I have a LINQ statement that generate an anonymous type, for example:
BookID, AuthorID, [Authors]*
Authors return a IEnumerable which also contains many authors, it has 2 columns: AuthorID and AuthorName
For example:
1 | 32 | 12, Author 1
20, Author 3
32, Author 19
How can I re-order the Authors object so that [32, Auth...
I have the following class
public class Element
{
public List<int> Ints
{
get;private set;
}
}
Given a List<Element>, how to find a list of all the Ints inside the List<Element> using LINQ?
I can use the following code
public static List<int> FindInts(List<Element> elements)
{
var ints = new List<int>();
foreach(var ele...
How to write a LINQ Expression (method call syntax preferred) that gives a list of fibonacci numbers lying within a certain range, say 1 to 1000 ?
...
I'm currently using NetTiers for all data access operations. While it is easy to use, it is a major pain to deal with template updates and regenerating DAL especially on large and constantly evolving projects. Aside from that, NetTiers is database-centric, not model-centric which is where i'd like to be. What i would like to do is try ou...
Hi Stackers,
I am looking for a structure that holds a sorted set of double values. I want to query this set to find the closest value to a specified reference value.
I have looked at the SortedList<double, double>, and it does quite well for me. However, since I do not need explicit key/value pairs. this seems to be overkill to me, an...