linq

LINQ with FoxPro?

Is there a reasonable way to access FoxPro databases using LINQ? ...

Linq to SQL: How do I stop the auto generated object name from being renamed?

In visual studio 2008, when I drag a database table into my dbml screen, any tables that end with the letter s automatcially get the s removed from the dbml object. Is there any way to disable this? Also, the collection of rows also gets an s appended to the collection property name. Is there a way to change that as well? Thanks ...

Using Linq with stored procedures

Hello, I want to plan a data access layer and I thought to use Linq. I read that linq has its problems with performance and that you could use stored procedures with linq. Should I use stored procedures with linq when planning my data access layer? Is it crucial for the performance? When should I use them? I know that stored procedures...

Linq to Entities, Table per Type and Nullable Foreign Key Relationships.

Hey, I'm using Linq to entities applying a Table per Type approach. This has been going very well, up to now. I have the following setup: Parent Table Child Table (Inherits from parent) Grand Child Table (Inherits from Child Table) Linking Table (Has Foreign Key Nullable, to Child Table) Here is the database diagram Following the...

LINQ to SQL: Multiple / Single .dbml per project?

I've read Rick Strahl's article on Linq to SQL DataContext Lifetime Management hoping to find some answers on how I would manage my .dbml files since they are so closely related to DataContext. Unfortunately, Rick's article seems to be focused on DataContext lifetime at runtime though, and my question is concerned with how the .dbml's s...

LINQ To SQL: Delete entity (by ID) with one query

I've been working with LINQ To SQL for a little while now and when it comes to removing an entity from the DB, I've always called the table's .DeleteOnSubmit and passed in the entity. Sometimes I've found myself writing something like: db.Users.DeleteOnSubmit(db.Users.Where(c => c.ID == xyz).Select(c => c).Single()); This of course ca...

Why and When to use LINQ ?

i have never used LINQ in any of my projects , i have always used ado.net /OR tool in my Business App projects , so i want to know What are the benefits of LINQ ? why and when anybody should use LINQ ? ...

Inheriting the equality comparer

I have a Customer class. public class Customer { private string _id; private string _name; // some more properties follow I am inheriting the EqualityComparer form MyEqualityComparer(of Customer). This I am intending to use in LINQ queries. MyEqualityComparer is intended for partial check between two objects. If the custom...

LINQ: Max or Default?

What is the best way to get the Max value from a LINQ query that may return no rows? If I just do Dim x = (From y In context.MyTable _ Where y.MyField = value _ Select y.MyCounter).Max I get an error when the query returns no rows. I could do Dim x = (From y In context.MyTable _ Where y.MyField = value _ ...

Are LinQ Queries above different LinQ providers possible?

I'm currently thinking about a repository pattern for my data objects, where multiple IQueryable<> instances can be registered as data sources. But it seems its not so easy to get it running :-) Running a simple LinQ Query with Linq to entities and linq to objects doesnt work. Do you think this is in general possible? Maybe the only sol...

Timesheets: Retrieve data using SQL, LINQ or class?

My problem is that I want a grid that is populated with a set of times spent on tasks. It needs to have the days of the week at the top (these would preferably be fixed - i.e. Sun, Mon... Sat) and task names down the left column. The contents of the grid will have the individual hours spent for that day on that task. What would the be...

Using LINQ to query flat text files with fixed-length records?

I've got a file filled with records like this: NCNSCF1124557200811UPPY19871230 The codes are all fixed-length, and some of them link to other flat files (sort of like a relational database). What's the best way of querying this data using LINQ? This is what I came up with intuitively, but I was wondering if there's a more elegant wa...

Linq to Sql query using "not in"

Can linq to sql query using not in? e.g., SELECT au_lname, state FROM authors WHERE state NOT IN ('CA', 'IN', 'MD') ...

How do I Create an Expression Tree by Parsing Xml in C#?

Hi, I am looking to create an expression tree by parsing xml using C#. The xml would be like the following: <Expression> <If> <Condition> <GreaterThan> <X> <Y> </GreaterThan> </Condition> <Expression /> <If> <Else> <Expression /> </Else> <Expression> or another example... <Expression> <Add> <X> ...

How to retrieve Stored Procedure schema using Linq to SQL?

Basically I am trying to retrieve a list of stored procedure parameters using Linq to SQL? Is there a way to do this? ...

Returning empty collections

Check out this test: [TestFixture] public class Quick_test { [Test] public void Test() { Assert.AreEqual(0, GetByYield().Count()); Assert.AreEqual(0, GetByEnumerable().Count()); } private IEnumerable<string> GetByYield() { yield break; } private IEnumerable<string> GetByEnumerable() { ...

Problem refreshing tables in the LINQ to SQL designer

I have been using LINQ to SQL for a while, and there is one thing that has always bothered me. Whenever I modify the schema of a table, in order to refresh it in the designer, I have to delete it and then add it back. That's fine, but this means I have to actually find the table in the designer. I have about 100+ tables in my database,...

Using Linq and the Trim.Text for Search

I am trying to convert this test code to C# and having a problem with the Trim command. Has anyone done anything similiar like this in C# going to use this with a text box for searching the aspx page. Dim q = From b In db.Blogs _ Where b.BlogContents.Contains(txtSearch.Text.Trim()) Or _ b.BlogTitle.Contai...

LINQ for Java tool

Would a LINQ for java be a useful tool? I have been working on a tool that will allow a Java object to map to a row in a database. Would this be useful for Java programmers? What features would be useful? ...

Simple tutorial for Linq

Hi, can someone suggest a simple overview about Linq that is best suited for a programmer who is already familiar with the concept of Linq but doesn't know the syntax? Thanks! ...