linq

How to get value of Expression<Action<T>> action quickly?

Suppose we have the following code: ExpressionHelper.GetRouteValuesFromExpression<AccountController>(ax => ax.MyAction("a", "b")); (from ASP.NET MVC Futures assembly). Method is reasonably fast - it executes 10k iterations in 150ms. Now, we change code to this: string a = "a"; string b = "b"; ExpressionHelper.GetRouteValuesFromExpre...

.NET 2.0 or 3.5?

Our clients use a vb6 version of our software. We are upgrading them to a .NET application written in C#... Is there less bulk using .net 2.0 than .net 3.5? My definition of less bulk would be: Smaller size, smaller installation time, etc. Most of them probably already have 2.0 anyway. I only ask because I would like to take advanta...

convert Request.QueryString toDatetime and then fetch using datacontext in linq in c# asp.net

Hi, I wanna get the Timedate value from another page using request.querystring and then use it an query to compare and pull up the matching datas. The function for the query in linq is: protected void User_Querytime() { DataClasses2DataContext dc1 = new DataClasses2DataContext(); String Data = Request.QueryString["TimeO...

Can I use LINQ to convert a List<MyObjectType> into a DataSet?

I am completely new to LINQ in C#/.NET. I understand that I could use it to convert a DataSet into an Array/List, am I able to go in the opposite direction? I'm using NPlot to generate a graph of captured prices, which are stored in a List, where PriceInformation is a class containing two public doubles and a DateTime. Any suggestio...

Linq to Entities with WCF

Hi there, I have all my entities in a seperate project in my edmx file and I expose them to my client application using a WCF service. That means I don't have to give my client app a direct link to the project that contains the edmx file. That would be bad because it contines the object to query the database with. But only the entitie...

Easy way to flatten XML file with LINQ

Is there an easy way with LINQ to flatten an XML file? I can see a number of ways with XSLT but wondered what the best option with LINQ would be? I cant put the xml structure up exactly as stackoverflow seems to filter chevron chars. But its something like this nodeA --nodeA1 --nodeA2 NodeB I want to end up with nodeA nod...

How to update a single column in LINQ without loading the entire row?

In LinqToSql, it is lovely easy to load a row, change a column, and submit the changes to the database: using (MyDataContext wdc = new MyDataContext()) { Article article = wdc.Article.First(p => p.ID == id); article.ItemsInStock = itemsinstock; wdc.SubmitChanges(); } The only drawback: Article is huge. To load the entire...

Linq to XML 'Where not in' syntax problem

The following Code does not compile Dim BasicGroups As String() = New String() {"Node1", "Node2"} Dim NodesToRemove = From Element In SchemaDoc.Root.<Group> _ Where Element.@Name not in BasicGroups For Each XNode In NodesToRemove XNode.Remove() Next It is supposed to Remove any Immediate child of the rootnode w...

Nested transactions in LINQ to SQL

I need help with realizing quite complex business logic which operates on many tables and executes quite a few SQL commands. However I want to be sure that the data will not be left in incosistent state and to this moment I don't see the solution which would not require nested transactions. I wrote a simple pseudo-code which illustrates ...

Time date conversion in linq

I wanted to compare the datetime which is in this format "7/20/2008" with the ones in the database which is in format "7/20/2008 7:14:53 AM". I tried using "like" clause but it did not work beacuse the "like" clause uses only string and the one which I am using is date time format. Can anyone tell how to convert and compare it in datab...

How to assign null to sql entity columns

I have generated linq to sql entites but cannot figure out how to assign null to a nullable column. whenever i try to assign null to it it says "there is no implicit type conversion between int and ". BTW the type of the field is int? and the database column is also nullable. ...

create hyperlink in gridview asp.net c#

My code is in c# asp.net 3.5 In the following code the "Msg" has many words with spaces and characters (eg:Failed to prepare Sync Favorites : Directory does not exist: \STL-FNP-02\ryounes$\Sync\Favorites). This "Msg" is pulled from database to a gridview. I am not able to create hyperlink for this "Msg" in gridview. Since it has spaces ...

Checking for duplicates in a complex object using Linq or Lamda expression

I've just started learning linq and lamda expressions, and they seem to be a good fit for finding duplicates in a complex object collection, but I'm getting a little confused and hope someone can help put me back on the path to happy coding. My object is structured like list.list.uniqueCustomerIdentifier I need to ensure there are no d...

Change order of XML using XDocument

I want to change the order of XML using XDocument <root> <one>1</one> <two>2</two> </root> I want to change the order so that 2 appears before 1. Is this capability baked in or do I have to do it myself. For example, remove then AddBeforeSelf()? Thanks ...

Cleanest syntax to delete a record in linqtosql

What is the best way to delete a database record using LINQ when I have the primary key? ...

Is it possible to use Full Text Search (FTS) with LINQ?

I wonder if is possible to use FTS with LINQ using .NET Framework 3.5. I'm searching around the documentation that I didn't find anything useful yet. Does anyone have any experience on this? ...

How to check for the presence of an OrderBy in a ObjectQuery<T> expression tree

I'm using t4 for generating repositories for LINQ to Entities entities. The repository contains (amongst other things) a List method suitable for paging. The documentation for Supported and Unsupported Methods does not mention it, but you can't "call" Skip on a unordered IQueryable. It will raise the following exception: System.Not...

What is the best way to sort using a GridView and LINQ?

The one thing that LINQ seems to be missing for me is a way to reference columns by text string. For example, I have a typical GridView set up with sorting like this (the DataSource is bound to a LINQ query in the code-behind): <asp:GridView ID="MyGridView" runat="server" AllowSorting="True"> <Columns> <asp:BoundField DataFi...

Validating and Extracting XML record by record into Database

Here's the deal. I have an XML document with a lot of records. Something like this: print("<?xml version="1.0" encoding="utf-8" ?> <Orders> <Order> <Phone>1254</Phone> <City>City1</City> <State>State</State> </Order> <Order> <Phone>98764321</Phone> <City>City2</City> ...

LINQ to SQL concurrency conflict - Looks like a clean attach with proper row versioning

I am trying to get LINQ to SQL to persist changes to an attached object wherein the backing table has a DateTime column that I think should function for row versioning, as described here. The table looks like this: CREATE TABLE [dbo].[client]( [client_id] [int] IDENTITY(1,1) NOT NULL, [client_address1] varchar(100) NULL, /* snip */ [mo...