linq

LINQ or ADO.net Entity Framework - which to learn?

A bit of a clarification: I was browsing Julia Lerman's Oreilly title on Entity framework and I got mighty confused. I have Charlie Calvert's essential LINQ, but from my 10 minute session with Lerman's book, it transpires that LINQ is LINQ to SQL which seems underpowered with its DataContext object etc... Whereas Entity Framework is th...

linq to sql group by having

Could any one show my how to write query using linq to sql to search for suburbs which have at least 1 venue in specific state Location SuburbID SuburbName StateName Venue VenueID VenueName SuburbName StateName ...

C# INotifyPropertyChanged on properties of a dynamically created object?

(update) ICustomTypeDescriptor works for my Windows Forms app, but not for Silverlight; Not supported. I will keep investigating this idea though and see where i get to. (/update) I have, say a few switch panels (for those that like analogies). Each of these switch panels has switches that have a Name(string) can be in state(bool) of On...

How to rollback the datacontext to the point of the last submitchanges

I am working on an app that is inserting a lot of new objects (rows) and relationships between them. But at a certain point when an error occurs I want all the changes to the DataContext be disgarded and "thrown away". So that after an error I have a clean copy of the DataContext that matches the state of the database. ...

How to use transactions with a datacontext

Can i use transactions with a datacontext, so i can rollback the state of the context after an error. And so yes, how does it work? ...

Bulk-deleting in LINQ to Entities

Is there any way to bulk-delete a bunch of objects matching a given query in LINQ or LINQ-to-Entities? The only references that I can find are outdated, and it seems silly to iterate over and manually delete all objects I wish to remove. ...

Linq to XML to Generate DDLs

We're storing out database definition as XML in the format at the end of this question. The problem I'm having is getting a list of schemas, the tables in those schemas, the columns in those tables (all with their associated information). My current code (included below the sample XML) grabs everything, completely ignoring nesting and, d...

Best way to delete multiple records in a LINQ query?

What is the best way to multiple records in one go in LINQ? ...

GetChangeSet ChangeSet, Linq what order will changes be applied?

I am running the code to get the change set just before a linq submit changes call. private void OnSubmitHandleReplication() { System.Data.Linq.ChangeSet changes = GetChangeSet(); //Do something with change set } In the do something section I need to know what order things were submitted in, and what order they will post to th...

linq multiple columns; getting weird results

So m.SourceCollection has 1000 records going into this, which is a collection of items with a Lat and Lon property; nothing else. I run this: var results = from locs in m.PlacesBeen group locs by new {locs.Lat, locs.Lon } into myGroup select new { Lat = myGroup.K...

IQueryable Where Extention Method with Or's

Duplicate: http://stackoverflow.com/questions/782339/how-to-dynamically-add-or-operator-to-where-clause-in-linq I want to loop through a array of string values and build a linq expression Where each item in the list is OR'ed together. string[] search = new string[]{"A", "B", "C"}; foreach (string item in filterValues) { se...

How do I use Linq in MonoDevelop 2.0 on OS X?

I installed MonoDevelop 2.0 on my Mac. I created a new Console Application. "Hello World" program runs fine. But I can't use Linq. "using System." doesn't show "Linq" option. What should I do? Thanks. ...

Ways of accessing MySQL from C#/WPF

Hi, I'm new at WPF and C# and I'd like to know the best way of accessing MySQL. Googling a little bit I've seen there's a Linq provider for MySQL. Is that the best way? http://code2code.net/DB_Linq/ I've never used Linq before so I'll start today unless somebody knows a better way of doing that. Thanks in advance ...

LINQ performance - deferred v/s immediate execution

I have seen that sometimes the performance of LINQ to Objects queries can be improved significantly if they forced to execute immediately by using .ToArray(), but can't quite understand why. For example, in the sample below, the execution of the function Deferred() is much slower than the function Immediate(), and grows exponentially wit...

How to get unique First Letter of names and count of names starting with that letter from SQL Server using LINQ?

Hello all. I was playing with ASP.NET MVC 1.0 a couple of days ago. I started out with a single table DB named 'Contacts', with very simple structure e.g. Title, FullName, SurName, Email, Phone, Address etc. I'm using LINQ as my Model. In my main view I wanted to display a list of alphabets that have matching FullNames starting with t...

How to transform an enumeration of long to a single string with LINQ

Hello all, I am wondering if there is an easy and clean way (one line) to transform an enumeration of long (IEnumerable) to a single string (string) with LINQ? Thanks ...

Convert my SQL to LINQ

hi this is my code that I write it but I want to use LINQ , can you help me for conver this code to LINQ ? /// <summary> /// Stores the request in the PublisherRequests table and /// the selected categories in the PubReq_Categories table. /// </summary> /// <param name="UserId">The user's ID logged in.</param> /// <param name="Url">URL...

Do you have to have SQL Server installed on a machine if the connection string using is a path to a .mdf File?

I am wondering if you can use Linq to SQL using a .mdf file on a machine without a SQL Server instance installed? ...

asp.net mobile 2.0

i am trying to send the value id inorder to connect 2 pages. the search page with the comments page. this is the error i get Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code Exception D...

How to combine 2 LINQ into one

I am trying to populate a treeview control with some info and for that I am using 2 separate LINQ as follows; Dim a = From i In CustomerTable _ Group By ShipToCustName = i.Item(6), BillToCustName = i.Item(4) Into Details = Group, Count() _ Order By ShipToCustName Dim b = From x In a _ Group...