linq

How can I reject all changes in a Linq to SQL's DataContext?

On Linq to SQL's DataContext I am able to call SubmitChanges() to submit all changes. What I want is to somehow reject all changes in the datacontext and rollback all changes (preferable without going to the database). Is this possible? ...

strip out tag occurrences from XML

I'd like to strip out occurrences of a specific tag, leaving the inner XML intact. I'd like to do this with one pass (rather than searching, replacing, and starting from scratch again). For instance, from the source: <element> <RemovalTarget Attribute="Something"> Content Here </RemovalTarget> </element> <element> More...

Adding Nodes to Tree via LINQ creates "query operator not supported" during runtime

I am trying to get my head around a LINQ issue. The ultimate goal is to load tree view with data acquired from LINQ to SQL (view). The issue is when I try to access the data acquired it keeps throwing a "query operator not supported during runtime". The code involved is no more than: Dim tasklistdata As New lqDataContext Dim Use...

LINQ to Array in Silverlight 2

There's something wrong with my code or I'm just not understanding this fully. I have the following code that runs a query that MAY contain more than one RIGHT attribute and want to store each within an array for later fetching: var members = from myList in o_data.Descendants(bp + "Reaction") select n...

How do I use LINQ to Entities in Visual Basic?

I've created a .NET solution with two projects: ToyData (Visual Basic Class Library) ToyOne (Visual Basic WPF Application) The ToyData project contains Toy.edmx, an ADO.NET Entity Data Model generated from a database called Toy. The ToyOne project contains this Window1.xaml.vb file: 1 Imports ToyData 2 3 Class Window1 4 ...

How do I extend ADO.NET Entity Framework objects with partial classes?

I've created a Visual Basic WPF Application project that contains Toy.edmx, an ADO.NET Entity Data Model generated from a database called Toy. Its Window1.xaml.vb file looks like this: 1 Class Window1 2 3 Private Sub Window1_Loaded( _ 4 ByVal sender As System.Object, _ 5 ByVal e As System.Windows.RoutedEventArgs...

How do I use 'Order By' to sort on a property of an inherited type in LINQ-to-SQL?

Hi, I have a fairly standard inheritance situation in my current LINQ-to-SQL project. I have a base class called 'Party' and classes called 'Individual' and 'Organisation' which inherit from it. What I want to achieve seems (and probably is) fairly simple. I want to return a list of 'Organisations' sorted by Company Name. The problem i...

Does WCF suppress first-chance exceptions?

I've got a WCF service that uses a LinqToSql DataContext to fetch some information out of a database. The return type of the operation is IEnumerable<DomainObject>, and I have a helper method that converts from the Table-derived LINQ object to a WCF data contract like so: [OperationContract] public IEnumerable<DomainObjectDTO> RetrieveD...

Weird behaviour when running ClickOnce deployed version of WPF application

Hi, We have a Navigation Based WPF application. It works fine when running directly from Visual Studio, or even if we copy the files to another directory or another computer and run it there. We deploy the application over the internet using ClickOnce and most of the time this does not cause any problems. Every now and then however, i...

Obtain max length for a "string" column using LINQ To SQL

Is it possible to obtain the maximum column length for a VARCHAR, CHAR etc? ...

Addicted to LINQ

Ok, the more I use LINQ, the more I like it! I recently found myself working in some legacy code at work. It is your classic DataSet and DataTable rich application. Well, when adding a bit of functionality I found myself really wanting to just query the rows of a DataTable for the results I was looking for. Let me repeat that... instead...

Integrating Linq in a Classic ASP Site

This project is the probable first step in migrating a large CMS from Classic ASP to .Net. I'd like to use LINQ for querying the DB. Does anyone have any ideas for strategies to make this happen? I understand this is a vague question at this point, but I'm gathering information. Thanks, KevDog ...

How do I put business logic in my ADO.NET Entity Framework classes?

I'd like to use the ADO.NET Entity Framework for data access, extend its objects for my business logic, and bind those objects to controls in my UI. As explained in the answers to another question, I cannot extend ADO.NET Entity Framework objects with partial classes and use my custom methods in LINQ queries. I don't want methods sho...

SQL 2 LINQ query (called by databinding) completely freezing WPF application

Earlier today I was hunting down a very weird bug... I finally traced it down to what seems to be causing the problem. The original report can be found here: original question The details have changed enough to warrant a new question. It would seem my application sometimes, NOT ALL OF THE TIME, freezes when it reaches the following LI...

Set LINQ DSN for DataContext

Hi, I normally store all my configs in the registry. Even though I have started using LINQ I would not like to have the DSN in the web.config, but rather let it stay in the registry and attach it (maybe in the Application Start Event) to the System Config. How can this be done? Thanx for any ideas! edit: to make it clear: I do not wa...

Entity Framework & LINQ To SQL - Conflict of interest?

I've been reading on the blogosphere for the past week that Linq to SQL is dead [and long live EF and Linq to Entities]. But when I read the overview on MSDN, it appeared to me Linq to Entities generates eSQL just the way Linq to SQL generates SQL queries. Now, since the underlying implementation (and since SQL Server is not yet an ODB...

Deleting records in LINQ with foreign keys - invalid cast exception

I have a simple database: ARTICLE ---------- ArticleId (PK), ArticleTitle ..other stuff... USER-ARTICLE ------------ ArchiveId (PK), UserId, ArticleId ..other stuff... The articleId's are foreign keys. I want to be able to delete a user article row by UserArticleId using the following code UserArticle myobjtodelete = PersonalArc...

LinqToEntities not retrieving child objects of an entity

Hi guys, I'm trying out Linq for the first time and having a bit of difficult retrieving the child objects of an entity. I have a course table which has a one to many relationship with the department table (ie. one department can have one or many courses). When I select the a particular department I want to bind the courses relating ...

Accessing dynamically created stored procedure from LINQ

Hello! I'm pivoting data in MS SQL stored procedure. Columns which are pivoted are dynamically created using stored procedure parameter (for exampe: "location1,location2,location3,") so number of columns which will be generated is not known. Output should look like (where locations are taken from stored procedure parameter): OrderTi...

Getting odd/even part of a sequence with LINQ

Say I have a list of all Projects, and that I group them by category like this: var projectsByCat = from p in Projects group p by p.Category into g orderby g.Count() descending select new { Category = g.Key, Projects = g }; Now I want to display this as a list in a web page, ...