linq

How to extract a meta tag from XML/HTML using Linq?

I am trying to parse a bit of data from an HTML file, but my Linq statement is not working. Here is the XML/HTML. Below, how can I extract the string "41.8;12.23" from the geo.position meta tag? Thx!! Here is my Linq String longLat = (String) from el in xdoc.Descendants() where (string)el.Name...

Trouble with SQL CE and Linq

I'm trying to get my program to use a LocalDataCache. I'm using Linq. if (tempVehicle.VehicleFinancialInfo[0].askingPrice != null) { // do stuff } askingPrice is a (decimal?) because VehicleFinancialInfo is a linq entityset. The above if test works on SQL Express but it crashes the app in SQL Compact Edition. It gives the error "...

C# Lambda Expression not returning expected result

I am using a lamda expression to filter a query. Basically, I have lines that are composed of segments and these segments are marked as deleted, inserted or null. What I want returned are segments that have been marked as deleted but whose any sibling IS NOT marked as deleted. As an example, Line: "Soylent Green is people!" Broken ...

linq where clause not in select statement

Can someone help me to convert from SQL Query to LINQ VB.NET: select rls.* from Roles rls(nolock) where rls.id not in ( select r.ID from usersRole ur (nolock) inner join Roles r(nolock) on ur.RoleID = r.ID where user_id = 'NY1772') Thanks ...

Does "LINQ to DQL" exist?

If LINQ-to-SQL overcomes the object-relational impedance mismatch of a .NET application talking to a SQL Server database... If I want to build a .NET MVC UI, where my model queries a Documentum CMS database... Is there a LINQ to DQL (Documentum Query Language) library ? ... ... that will help me overcome the object-relational impedan...

What is "Linq to SQL"?

I've had a discussion with a colleague about "Linq to SQL". I am still new at .NET so he thinks I need to learn more. (still, 30 years of general programming experience should count in my advantage, right?) I had read some books and for a new project I decided to use the ADO.NET Entity Data Model. My colleague disagreed because he "knew"...

Using relationship/foreign key with linq2sql?

Hi there, Can anyone help? I have a created a relationship between my Reservation(prim key) and Insurance(for key) tables and imported into linq2sql and checked my automatically created c# files and sure enough i have reservation.MyFieldNames etc etc PLUS reservation.Insurance which is my relationship but reservation.Insurance i can't ...

Is necessary to compile linq queries in subsonic?

I'd like to know if it's necessary to compile linq queries to the subsonic entities? For example would I'd need to compile the following linq query? var comments = from a in All() where a.ParentCommentId == ArticleCommentId select a; ...

Using xname in Linq-to-xml

I am writing some code to generate an opml file from a list of rss feeds (parsed) on my site. The user will select checkboxes from a datagrid of rss feeds on my site, and when pressing a button, the heavy lifting will happen. Anyway, I have code like this: foreach (var v in list) { XName xname; doc.Element("ch...

Generic Repository Linq2Sql impedence mismatch problem

I am working on a repository pattern where the API look as follows: var visitor = repository.Find(x => x.EmailAddress == credentials.EmailAddress && x.Password == credentials.Password); where visitor is a domain object and x represents this domain object. The method signature of the Find method on the re...

Linq List<string> union

How can I use Linq to find common items between 2 generic lists of type string. For example, say I have the following code, I would like to get a List < string> which would contain item2 and item3: List<string> List1 = new List<string>(); List<string> List2 = new List<string>(); List1.Add("item1"); List1.Add("item2"); List1.Add("item...

How to skip record that cannot be inserted in vb.net

Hello, I am looping through several hundred records from a XML file and inserting in SQL server 2008 using LinQ from my Web Service. My question is, for some reason if a record is not inserted it is coming out of the loop and going to the Catch block directly. How do I move to the next record if the insert fails and continue with the ...

Read a specific Element Value based on a specific Attribute in Linq?

I'm just learning Linq, and stuck on what I hope is fairly simple. My xml document is like: <?xml version="1.0" encoding="utf-8"?> <XDOC> ... <ItemsDetail> <Item name="Item1"> <data1> <Data type="classA">55</Data> <Data type="classB">66</Data> </data1> <...

Trying to find the top 3 properties of a POCO instance, Part 2

Hi folks, a month ago I asked this question: Trying to find the top 3 properties of a POCO instance. Got an answer, worked well. Now, I'm trying to find the top 3 properties of a POCO object (like my previous question) but where each property has a WEIGHT. The value of the property comes first. The weight then comes in second ... if tw...

Enumerable.Except does not use my custom comparer

Hello folk, I try to use the except method with a custom equality comparer, but it is not work. My equality comparer: public class BusinessObjectGuidEqualityComparer<T> : IEqualityComparer<T> where T : BusinessObject { #region IEqualityComparer<T> Members /// <summary> /// Determines whether the specified objects are equa...

What's the cleanest way to make a Linq object "dirty"?

I have a Linq-To-SQL object obj of type MyClass that I have loaded via my data context. Now I want to force that object to save, even if no fields have actually changed, so that the save action can set off some triggers behind the scenes. What's the easiest way of making my data context think that obj is dirty, so that a call to Submit...

SubSonic 3.0.0.3 | SimpleRepository - SortBy [SubSonicIgnore]

I got a class with [SubSonicIgnore]: [SubSonicIgnore] public string Name { get { return (FirstName ?? string.Empty) + ((MiddleName ?? string.Empty).Length > 0 ? " " + MiddleName + " " : " ") + (SurName ?? string.Empty); } } whenver I run my test: [Test] ...

Editing Linq results in a GridView

I have the following Linq Query which links data from SQL Server and an ODBC source (Cache as it happens) Dim items = _ From p In dtCurrentPatients.AsEnumerable() _ Group Join s In dtScores.AsEnumerable() _ On p.Field(Of String)("HospitalNumber") Equals s.Field(Of String)("HospitalNumber")...

How to make a linq Sum return null if the summed values are all null

I have a link query that looks like this... var duration = Level3Data.AsQueryable().Sum(d => d.DurationMonths); If all the d.DurationMonths values are null the Sum returns 0. How can I make the Sum return null if all the d.DurationMonths are null? Or do I need to run a seperate query first to eliminate this situation before performing ...

Find first element of certain type in a list using LINQ

What would be the shortest notation to find the first item that is of a certain type in a list of elements using LINQ and C#. ...