linq

Regular Expression is missing empty values?

Dim re As New Regex("((?<field>[^"",\r\n]+)|""(?<field>([^""]|"""")+)"")((?<rowbreak>,\r\n|\r\n|\n|$)|,)") 3700,Collin,Franc,,[email protected],Collins,Francine,,[email protected],"Enel North America, Inc.",One T Drive,Suite 220,MyCity,MA,77774,1,[email protected],,,,,3700, 3701,Steur,Larry,,[email protected],Steur,Larry,,[email protected],...

Can you use LINQ with in memory objects rather than SQL Server queries to improve performance?

We have been developing a DB web app which constantly queries an SQL store of objects (about 80,000 of them) which are related to each other in a hierarchy. (i.e. many objects have parentid which relates to another object in the same table) I have been thinking that loading the entire object tree into memory and querying the objects usi...

LINQ grouping in C#

I'm puzzled. I copied this code from the Microsoft LINQ examples site, but can't get it to compile. I want to do something similar, but it says it cannot resolve symbol minPrice, and a bunch of other errors. What gives? public void Linq84() { List products = GetProductList(); var categories = from p in products g...

Generic list in an interface

I am trying to implement an interface class, that contains a list of objects. How can I make the list generic, so that the implementing class defines the type of list: public interface IEntity { Guid EntityID { get; set; } Guid ParentEntityID{ get; set; } Guid RoleId { get; set; } void SetFromEntity(); void Save(); ...

How do i get the Sum in this Linq query?

Hi folks, i have a table that has zero to many children. just like how this site has a QUESTION which can have zero to many VOTES (either Up == 1 or Down == 0). I need to get all questions that have the most up votes. Eg. all the questions, ordered by Sum(Vote) descending. I'm not sure how to do it in linq. So i would have an EntityS...

LINQ to Objects - Philosophy of use?

I am starting to explore LINQ to Objects but want to know how application design can best accommodate LINQ to Objects. As an example .... an application displays female employees only and the employee table in the database contains data for both male and female employees. By default, the application builds a SQL statement to retrieve ...

How change List<T> data to IQueryable<T> data

Possible Duplicate: IList<T> to IQueryable<T> I have a List data, but I want a IQueryable data , is it possible from List data to IQueryable data? Show me code ...

ASP.NET MVC Service Layer Updates with LINQ

I have been looking at the examples for updating models in the MVC architecture. There are plenty updating the model where the linq (SQL or EF) is in the controller. And there are others where the service layer is used to fetch values. The only example I can find its going to be awkward to use with an IoC container. What I'm looking to ...

How to rollback changes to WPF DataGrid control using LINQ-to-SQL?

I was able to set up a WPF Datagrid, display a Northwind database table via linq-to-sql, and handle the TheDataGrid_RowEditEnding event so that it saves back the the database. However, when a CustomerID was changed, it gets an error from the database which I handle, but how do I now either (1) rollback the Datagrid control or (2) refetc...

Object Relational Mappers in .NET and stored procedure usage

Given that they generate the Create, Read, Update, and Delete (CRUD) functionality for you in most cases, does this imply that stored procedures won’t be used as often? If these methods use LINQ then that means no stored procedures are used, correct? Any clarification is greatly appreciated. ...

How can I allow user to sort columns on a LINQ-to-SQL WPF Datagrid?

I have successfully set up a WPF Datagrid with the March 2009 WPF Toolkit, created LINQ-to-SQL classes from the Northwind database, bound the WPF grid with this code: var customers = from c in _db.Customers select c; TheDataGrid.ItemsSource = customers; I can move columns from left to right, got delete columns to work...

Set ViewData outside the controller

I'm trying to create a logger that will write the queries LINQ executes to the page formatted with the great javascript library SyntaxHighlighter. For that, I've set the DataContext's Log property to my custom logger, which is working well. Now I just need to get the current Controller object (outside the controller execution context) ...

Query By Entity (Example)

I’m looking for a tool that will dynamically generate Linq to Entity queries from a given entity, a Query By Entity (Example), if you will. Given an entity and the object context it belongs to, the generator returns an ObectQuery or IQueryable that could be further modified or executed. Ideally, the query builder would not directly ref...

how to authenticate ntlm to sql table using linq?

given 1. the initial idea, link text and 2. creating nested loops link text can I use linq here or how should I massage this to authenticate WindowsPrincipal to sql table? Thanks, -greg protected void Page_Load(object sender, EventArgs e) { string UserIdentityName = Server.HtmlEncode(User.Identity.Name); Boolean Match ...

Cache data. Sql and Sybase

Hey all, Ive been tasked to upgrade our existing extranet from .net 2.0 to 3.5. One of the main issues i had during the build phase for the 2.0v was the data was coming from SQL server 2005 and a legacy db in Sybase 9. To achieve this i basically made to Dataset's accordingly based on SPROCS and a third DS to merge. This then would...

Join in linq

Hi, is it possible to make a join in linq and only return data from one dataset where the other key was present, a little like: var q = from c in customers join o in orders on c.Key equals o.Key select new {c.Name, o.OrderNumber}; and then instead of returning just the two records then returning customers like...

C# string manipulation problem

Here's a simple problem. I have an application that takes a phone number like "13335557777", and needs to reverse it and insert a dot between each number, like this: "7.7.7.7.5.5.5.3.3.3.1." I know I can do this with a StringBuilder and a for-loop to reverse the string and insert the dots, but is there a clever way to do this in LINQ ...

Multiple WHERE clause in Linq

I'm new to LINQ and want to know how to execute multiple where clause. This is what I want to achieve: return records by filtering out certain user names. I tried the code below but not working as expected. DataTable tempData = (DataTable)grdUsageRecords.DataSource; var query = from r in tempData.AsEnumerable() where ((r.Fie...

What options do I have for LINQ projections?

In LINQ, I'd like to project different names than those from the database tables. "Friendly names" that I can use for column headers. Names that have "%" or possibly a " " (space). The query below won't compile. Is something like that possible or am I stuck using the dreaded _ underscore for everything? dim query = from p in ctx.Som...

Combining resultset in C# using Linq

I have two tables 'toc' and 'content' with the following structure: toc id name(50) content id text(500) title(50) tocid I am searching the for some text within toc.name, content.text and content.title and require a single resultset. Is it possible to combine the search results using linq(c#). I want the resultset as something like...