linq

LINQ with SQLite (linqtosql)

I have a small project that require a storage (I choose SQLite) and I got good result with the ADO DLL for .Net for Sqlite. After the Install, I noticed that it contain a SQLLinq.dll. Before investigating too much effort, and because I haven't see any good example on the web, I would like to know if anyone got any good result with SQLit...

What would you choose for your data layer today, Linq or Subsonic?

We are ready to start a brand new project at work, no legacy code. We did use Subsonic in the past and we pretty happy with it. But that was before Linq. Has anyone had to face this same issue (Linq x Subsonic)? What was your decision? What were the reasons? Any insight appreciated. ...

Are LINQ expression trees Turing complete?

As they are in .Net 3.5. I know they are in 4.0, as that's what the DLR works with, but I'm interested in the version we have now. ...

What do i use instead of e.Values.add(... for the ListViewEditEventArgs to upload an Image

Hi, i can upload images to the database using linq and the listview control when referancing the e.Values method for the ListViewInsertEventArgs, but there is no such method in the ListViewEditEventArgs, so what can i use to achieve the same results? here is my inserting code: protected void ProjectPhotosList_ItemInserting(object sende...

"Most popular" GROUP BY in LINQ?

Assuming a table of tags like the stackoverflow question tags: TagID (bigint), QuestionID (bigint), Tag (varchar) What is the most efficient way to get the 25 most used tags using LINQ? In SQL, a simple GROUP BY will do: SELECT Tag, COUNT(Tag) FROM Tags GROUP BY Tag I've written some LINQ that works: var groups = from t in Dat...

Can I perform an "or" operation in LINQ to objects?

Looking up LINQ and Or in google is proving somewhat difficult so here I am. I want to so the following: (from creditCard in AvailableCreditCards where creditCard.BillToName.ToLowerInvariant().Contains(txtFilter.Text.ToLowerInvariant()) **or creditCard.CardNumber.().Contains(txtFilter.Text)** orderby creditCard.BillToName select credi...

Fetching items which has a specific set of child elements (advanced query - possible?)

Hi, I have a SQL database (SQL Server 2008) which contains the following design ITEM ID (Int, Identity) Name (NVarChar(50)) Description (NVarChar(200)) META ID (Int, Identity) Name (NVarChar(50)) There exists a N-N relationship between these two, i.e an Item can contain zero or more meta references and a meta can be associated ...

Product with LINQ

I am learning LINQ and have a very simple question that I think will help my understand the technology better. How can I find the product of an array of ints? For example, what is the LINQ way to do: int[] vals = { 1, 3, 5 }; return vals[0] * vals[1] * vals[2]; ...

How to write Asynchronous LINQ query?

After I read a bunch of LINQ related stuff, I suddenly realized that no articles introduce how to write asynchronous LINQ query. Suppose we use LINQ to SQL, below statement is clear. However, if the SQL database responds slowly, then the thread using this block of code would be hindered. var result = from item in Products where item.P...

Where are some good tutorials on writing a custom LINQ Provider?

I would like to build a custom LINQ Provider. Mostly for learning purposes, but it may be usefull in the future. I've heard it's not a simple thing to do, but... Where are some good tutorials on writing a custom LINQ Provider? ...

What is the difference between IQueryable<T> and IEnumerable<T>?

What is the difference between IQueryable<T> and IEnumerable<T>? ...

Best primary key data type for Linq to SQL

I am starting new project with SqlServer and Linq to Sql. What data type would be better for surrogate keys in tables: identity or uniqueidentifier ? As I understood, identity is automatically generated on insert, while uniqueidentifier should be generated in code (GUID). Are there any significant performance differences? e.g. ident...

Can take be used in a query expression in c# linq instead of using .Take(x)?

I'm trying to write some LINQ To SQL code that would generate SQL like SELECT t.Name, g.Name FROM Theme t INNER JOIN ( SELECT TOP 5 * FROM [Group] ORDER BY TotalMembers ) as g ON t.K = g.ThemeK So far I have var q = from t in dc.Themes join g in dc.Groups on t.K equals g.ThemeK into groups select new { t.Name, Groups = (fr...

LinQ ORM Data Objects and Inheritance.

I'm thinking about how to do this, but I have several different shapes of Data in my Database, Articles, NewsItems, etc. They All have something in common, they all have IDs (in the DB they're named ArticleID, NewsID etc. ) They all have a Title They all have BodyText. They all have a Status They all have a DateAdded What I'd lik...

How can I get my orderby to work using an anonymous type?

What do I put in my order by?? I want to order by Name. I have moved the orderby after the distinct because I read that it needs to be done last. var result = (from r in db.RecordDocs where r.RecordID == recordID select new { DocTypeID...

How can I perform a nested Join, Add, and Group in LINQ?

I have two objects, let's call them Input and Output Input has properties Input_ID, Label, and Input_Amt Output has properties Output_ID and Output_Amt I want to perform the equivalent SQL statement in LINQ: SELECT Label, Sum(Added_Amount) as Amount FROM (SELECT I.Label, I.Input_Amt + ISNULL(O.Output_Amt, 0) as Added_Amount FR...

Random array using LINQ and C#

I was reading an article on MSDN Magazine about using the Enumerable class in LINQ to generate a random array. The article uses VB.NET and I'm not immediately sure what the equivalent is in C#: Dim rnd As New System.Random() Dim numbers = Enumerable.Range(1, 100). _ OrderBy(Function() rnd.Next) ...

How to evaluate the pros and cons when changing language

Hi, I am working in a company that develops computing kernels. Their design is simple : it's a library in c++ which only has one function available to compute results out of available data. There are essentially four steps in every one of these kernels : retrieve xml content (format has been defined in an XSD file) and store into ob...

How should I get started learning about ADO.NET Entity Framework?

So here I am just about to start a big project using LINQ to SQL and then I read this: Is LINQ to SQL Truly Dead? by Jonathan Allen for InfoQ.com Well, I don't want to be supporting LINQ to SQL indefinitely if it's a dead end. So, how should I get started learning about ADO.NET Entity Framework? ...

When an Expression<T> is compiled, is it implicitly cached?

When an Expression<T> is compiled, is the resultant code implicitly cached by the framework? I'm thinking along the lines of the static Regex methods where the framework implicitly compiles and caches the last few regexes. If compiled Expression<T> objects are not cached, can you recommend some best practices for keeping the compile-tim...