linq

Subsonic 3 simple repository many to many relations

I saw in an earlier post here on stackoverflow a example on many to many relations. To keep it simple, lets have a look at these classes : public class Role(){ public int Id { get; set; } public string Rolename { get; set; } public string Description { get; set; } } public class User(){ public int Id { get; set; } p...

LINQ and nHibernate

NHibernate and LINQ both or for Object-Relational mapping,apart from different vendor API, what is the difference between nHibernate and LINQ ? ...

Linq "equals" keyword

Will the "equals" keyword in LINQ check for object at left and right points to the same memory or check for their content ? ...

Linq returning IEnumerable<T>

I wish to return enumerable items in order to bind the nested grid. Top grid displays Book Title and the nested grid displays the authors list of that book. Author Collection static public Author[] Authors = { new Author {FirstName="Johnny", LastName="Good"}, new Author {FirstName="Graziella", LastName="Simplegame"}, new Au...

Linq to Ntier samples

I am looking for Linq to nTier sample application. I can get the one at linq ntier http://blogs.msdn.com/bethmassi/archive/2008/04/12/linq-to-sql-n-tier-smart-client.aspx But the example is in VB.I need the one in C#. Help Please. Update I found the one at linq to Ntier in C# http://multitierlinqtosql.codeplex.com/wikipage?title=...

DOM and LINQ Difference

DOM and LINQ both are in-memory pattern. Apart from deferred execution,what is the difference between DOM and LINQ? ...

Tracking external changes to a database with LINQ-to-SQL

Is there a way to get SQL Server 2005 to call back to a connected application, such that the connected application will know when a record in a table has had a field modified by another application using the same database? A simple example would be two instances of the same application connecting to the same table in the same database. ...

ObjectDumper class in LINQ

I am learning LINQ.Several examples use ObjectDumper class.What is the use of ObjectDumper class ? ...

How to find items in a superset that are not in a subset

I know there's a "not" on ienumerable thanks to linq which takes a collection to not against, but I'm worried about big oh performance What's the fastest algorithm to do this? ...

DataContext.GetTable(Type) question

I just started using LINQ a couple of days ago and i'm stuck now. Given a certain type i need to recurse to the top. For example: hierarchy: Client, Project, Department. proposed function descriptor to load hierarchy: public static IEnumerable<object> LoadPath<T>(int id) where T : class, ContentItem, new() { } the user specifi...

Is it possible to clone an IEnumerable<T> instance, saving a copy of the iteration state?

I'd like to create a copy of an IEnumerator<T> so that I can restart the enumeration process from a particular location in the collection. Clearly, there is no benefit to doing so for collections that implement IList, since we can remember the index of interest. Is there a clever way to accomplish this task using a combination of yield...

LINQ : make select and update

Hello, I have this code foreach (MyType o in myList) { var res = from p in myOriginalList where p.PropertyA == o.PropertyA && p.PropertyB == o.PropertyB select p; //Need to update myOriginalList //.... } I'd like in the myOriginalList do an update for each record found by the Linq select. How can I do th...

ILASM for Compact Framework?

I'm working with Linq expression trees (from the db4o/Mainsoft/Mono port) on the Compact Framework. Since System.Reflection.Emit doesn't exist, I can't compile my LambdaExpressions into delegates, which I want to do for performance reasons. I thought maybe I could transform my expression tree into IL and basically provide the missing Em...

C# Conversion of CSV to XML using LINQ

The task is to convert the CSV file into XML. var x = from line in File.ReadAllLines(@"d:\sample.txt") where !line.StartsWith("#") && line.Length>0 let parts=line.Split(',') select new { XmlFile= new XElement("root", new XElement("ISBN",parts[0]), ...

Is Microsoft going to support SQL Server 2008 with LINQ in Visual Studio 2010?

Hello everyone, Is Microsoft going to support the features of SQL Server 2008 such as Hierarchyid and Filestream with LINQ in Visual Studio 2010 at last? Thanks P.S: Tired of having features in SQL Server that Microsoft's own tools don't support. Please let me know if it's worth the upgrade. ...

LINQ query to detect duplicate properties in a list of objects

I have a list of objects. These objects are made up of a custom class that basically contains two string fields (String1 and String2). What I need to know is if any of these strings are duplicated in that list. So I want to know if "objectA.String1 == objectB.String1", or "ObjectA.String2 == ObjectB.String2", or "ObjectA.String1 == Objec...

LINQ equivalent for the code?

I am absolute n00b at LINQ. Can code for GetAnimals() be written in LINQ? class Farm { ObservableCollection<Animal> allAnimals = new ObservableCollection<Animal>(); public IEnumerable<T> GetAnimals<T>() where T: Animal { foreach (var a in allAnimals) { if (a.GetType() == typeof(T)) ...

LINQ Select: different projects same code different results

The same code on two different web sites (on the same solution), VB.Net (framework 3.5). The Code: Public Class UserTest Public hhh As Integer Public fff As String Public Sub New(ByVal hh As Integer, ByVal ff As String) Me.hhh = hh Me.fff = ff End Sub End Class Dim lst As List(Of UserTest) = N...

What is the best way to transparently log changes to objects when using LINQ-to-SQL?

I keep track of all changes that are made to objects so that the user can view and rollback to any previous version of any item in the database. The history database table looks like this: Item | ItemId | Field | WhenChanged | OldValue | NewValue customer | 6 | LastName | 2009-12-31 13:00:04 | Sanders | Sanders-...

Writing XDocument to XLS

I am having my xml data in XDocument (LINQ). I want to write this data into excel data. I am using console application. I dont want to use excel com object. ...