linq

linq image saving problems

I have an object that has a property: [Column] public Binary Image { get; set; } When the object is saved the first time every this is OK, but when it is modified I get an exception on SubmitChanges: The data types image and varbinary(max) are incompatible in the equal to operator. What might be the problem here? ...

How do I Check previous data in LINQ?

I have a collection of data that checks if there is a change in a particular field to get the sum for another column. Total = Details.Where(s=>s.indicator != *prior indicator before this...).Sum(s => s.amount); ...

Spacing out output with Linq to Xml

How is it possible to force extra spacing between some nodes using Linq to Xml? I am looking to output the following: <root> <group> <leaf /> </group> <group> <leaf /> </group> </root> By adding Empty XText, it only destroys the formatting. var root = new XElement("root", new XText(""), ...

Learn LinqToSql or stick with ADO.NET?

I'm debating what technology to use for an upcoming ASP.NET project. Assumptions: I will be using Visual Studio 2008 SP1 (.NET Framework 3.5) The back-end will be a SQL Server 2005 database (or possibly 2008) Code will be written in C# I already have experience with LinqToObjects and LinqToXml I also have experience with ADO.NET and s...

Hierarchical structure iteration and LINQ

Hello! Assume that we have class public class RMenuItem { public List<RMenuItem> ChildrenItems { get; } public decimal OperationID { get; } public string Name { get; } } as you can see - each menuitem could have children items - as usual in menu. My task is to iterate through each items of this list and apply some action...

Grouping a list of of entities which has a sublist in c#

I have a set of Entities which basically has this structure. {Stats Name="<Product name> (en)" TotalResources="10" ..} {DayStats Date="2009-12-10" TotalResources="5"} {DayStats Date="2009-12-11" TotalResources="5"} {Stats} {Stats Name="<Product name> (us)" TotalResources="10" ..} {DayStats Date="2009-12-10" TotalResources="5...

How to run a mass update/delete query in Linq?

I have 2 Linq2Sql classes: Parent and Child. I want to do things like removing all children for a parent, or updating all child records. In SQL I would have written: delete Child where ParentID = @p or update Child set Val = Val+1 where ParentID = @p I can do this in Linq the brute force way inside the Parent class: Children.ToL...

what is inner equijoin?

Can someone please give me a simple explanation of an inner equijoin? I'm finding explanations found via google quite hard to understand. ...

Query HTML file with LINQ

Does anyone know if there's a library that will allow you to Query the HTML DOM with LINQ? Something like LINQtoHTML. Would it be useful to create such a thing if it does not exist yet? ...

storing large amounts of text in memory

If you need to be able to store a large amount of plain text in memory so it can be searched and edited, what kind of datatype would you use? Let's say I load a 10000 line document into my C# application for searching with LINQ, how would you represent it in memory? Not a string, because it's got be mutable, and strings are immutable. ...

Custom LINQ expression Gridview Bind

Hello all. I am following the good old Scott Gu LINQ to SQL guide to LINQ and have stumbled upon a query. Here is my scenario. I have a textbox a client should populate with a number (tbxHowMany), two radio buttons that define a material (radPaper & radGlass). A also have a button (btnReturn) that when clicked, a gridview (gridview1) ...

How might I complete this example using LINQ and string parsing?

I'm trying to write a simple program that will compare the files in separate folders. I'm currently using LINQ to Objects to parse the folder and would like to included information extracted from the string in my result set as well. Here's what I have so far: FileInfo[] fileList = new DirectoryInfo(@"G:\Norton Backups").GetFiles(); v...

Is SqlMetal a good solution for mapping to a database that contains *only* tables?

I'm thinking of using SqlMetal to auto-generate LinqToSql code for a simple and small database. The database will have only tables with some primary and foreign keys (i.e., no views, stored procedures, functions, etc.). I'd like to do all joins, grouping, sorting, and advanced data manipulation using Linq. I have experience with LinqToO...

What is the best way to databind Web Form controls to linq objects?

I have a typical object (it comes from Linq but it could have been create manually): public class Person { public string FirstName{get; set;} public string LastName{get; set;} public int Age{get; set;} } And I have a Web Form where users enter this data: <asp:TextBox runat="server" ID="FirstName"></asp:TextBox> <asp:TextBox run...

Mapping user fields from subtable

I have a database that I cannot change the format of. Custom objects are stored in a table called Custom_Independent that has several fields like text1,text2 and a app_name field that can be used as a distinguisher. Any additional fields are store in a seperate table User_Fields, there is also a User_field_defs table that contains the ...

Concatening objets with LINQ, under a condition

I'm new to LINQ, and I have trouble with a query I'm trying to write to teach myself LINQ. I have a list of MyError objects. A MyError object has a errorcode (an enum) and an arraylist of MyEntryError objects. Some MyError may have the same errorcode. I would like to create a LINQ query that take as input my list of MyError and outputs...

Gridview Sorting, Updating and Editing

Hello all - seasons greetings to you all. I really need some help as this is driving me mad. The aim. I have a textbox which a client enters a number, they click on a radio button list to select a material and hit a button to populate a gridview. This is the front end code: <asp:TextBox ID="tbxHowMany" runat="server" style="z...

ASP.NET - Enumerate through SiteMapNode.ChildNodes

Hello, I am reading in from my web.sitemap file, and I would like to apply a Linq OrderBy command to the ChildNode elements. However, I can't seem to access the OrderBy method to the ChildNodes property unless I first cast it to SiteMapNode (which is dumb because it's already of type SiteMapNode). Please point me in the right direction...

The benefits of a 3-tier architecture?

I'm not entirely convinced of the benefits of a 3-tier architecture. Why, then, has LINQ emerged, which is a lighter data access approach? Any input would be appreciated. ...

Linq to NHibernate : is it mature ?

Hi, I'm thinking about using Linq to NHibernate in an upcoming project, so I'd like some feedback about it. I found this identical question asked in February, and it seemed that Linq to NHibernate was not very mature at this time... Has it improved since then ? Has anyone used it in real life applications ? Thanks for your feedback PS...