linq-to-sql

Multiple DBML files - type sharing?

Hi, I have a Client/Server application, where the Client and Server have some common tables (which are kept in synchronisation as part of the application). We currently store these tables (i.e. FileDetails) in a Shared.dbml file. Until now, any stored proc that returns a result of set of FileDetails, has been placed in the Shared.dbml ...

Best Practices for Building a Search App?

I will be starting a simple datastore-and-search project soon. Basically, one of those "put my huge Excel spreadsheet into a database, build a web GUI for it, and make it searchable" type-things. One thing that's been bugging me is the actual search logic that will be used when the user enters some criteria. I am imagining a search inte...

Getting list of cities and countries from a SQL Table

I have a SQL table where in each row I store the country and the city of a things location. For example: record1, New York, USA record2, Rome, Italy record3, Milano, Italy record3, Birghiman, UK record4, London, UK record5, London, UK record6, London, UK record7, Birmingham, UK I would like to generate a list that is ordered by cou...

Need to retrieve List of items containing subitems matched with another List

Situation: I have some persons with certain skills and they can/might belong to more than one area. The skills are linked in a seperate table, so are the areas. I get the people list from selecting all persons with a match on each skill and add them to a list where I can use Distinct() to make sure that they dont show up twice. Result...

Linq to Sql Localisation query

Given the following tables I'd like to return the localised text for given culture or the text for the default culture where no row exist for the given culture. So with the folowing data Resources ID Name 1 Donkey 2 Elephant LocaleStrings ID CultureID ResID LocaleText 1 1 1 Donkey 2 1 2 Elepha...

Anybody else regretting using Entity Framework?

I have a project that implemented Linq To SQL, and I was pretty happy with it. For quite awhile the biggest problem was just that the designer was buggy. Unfortunately, my project now requires multiple table inheritance, and Linq to SQL does not support it. I decided to switch to Entity Framework when I learned that it does support mul...

How can I change content on my page based on the selected value of an HtmlHelper DropDownList?

Hello, I am using ASP.NET MVC and want to update content on my page based on the selected value of an HtmlHelper.DropDownList. I have an Admin page on which I would like to display a list of hired employees for a given semester, without having to redirect to another controller. Perhaps a table could be generated or a ListBox filled with...

Linq version of SQL "IN" statement

I have the following 3 tables as part of a simple "item tagging" schema: ==Items== ItemId int Brand varchar Name varchar Price money Condition varchar Description varchar Active bit ==Tags== TagId int Name varchar Active bit ==TagMap== TagMapId int TagId int (fk) ItemId int (fk) Active bit I want to writ...

Linq To Sql validation

I have a class containing Linq To SQL objects that are used to populate drop downlists on a view. Using Scott Gu's Nerd Dinner I am implementing the validation framework they use, using partial classes. This works fine when working with one object for (example dinner) per view. But when I use a class that is not a Linq To Sql object, I c...

Linq To Sql Search Multiple Columns and Multiple Words

I am trying to do an autocomplete search using a webservice and Linq To Sql to access the database. Here is my code. This returns results that match any of the search terms, I would like to modify this so each result contains all of the search terms. I'm aware that SQL full text search is probably the most elegant solution, but I'd lik...

How to handle programmatic addition of fields?

Yesterday, I asked this question regarding best practices for a simple information retrieval system I am beginning to work on. Today, my customer asked me if it is possible to allow them to add fields to the primary entity at a later date using the administration interface. That is, the application allows you to search across one databa...

Linq To SQL Attach/Refresh Entity Object

In Linq To Sql, when updating one of my entities, Faculty, I am creating a new instance of the Faculty object, then initializing some of the properties with values supplied by the user. If I attach this new object to the entity set, and submit changes, the properties that I didn't set take on the default value of whatever datatype they ...

How to build up a Linq to Sql where clause bit by bit?

I am being passed a set of querystring parameters within a Parameters class with which to query an image database. With each call some parameters may by null. So in sql I would build up the query like if (parameters.Value1 != null) { sql.Append("sql_where_clause"); } if (parameters.Value2 != null) { sql.Append("sql_where_clause...

Breaking sql statement in Linq in 2 or more parts, depends on program condition.

Hi everybody, I'm a principiant of Linq so i need some help.. I don’t know if in Linq syntax by breaking a query in 2 or more parts, just like the following example, the records will be downloaded immediatly from sql server in each step,or they will be sent to server at the moment when I’ll start to see all the data? for exemple when...

Linq to SQL DataContext Lifetime Management Issue

I read Rick Strahl's article about ways to deal with the data context. My DBML is inside a class library, I keep my data context open by creating a static Current method in a separate custom partial class within library. public partial class DataContext { public static DataContext Current { get { Dat...

How do I delete records from a child collection in LINQ to SQL?

I have two tables in my database connected by foreign keys: Page (PageId, other data) and PageTag (PageId, Tag). I've used LINQ to generate classes for these tables, with the page as the parent and the Tag as the child collection (one to many relationship). Is there any way to mark PageTag records for deletion from the database from wi...

LINQ to SQL updates

Does any one have some idea on how to run the following statement with LINQ? UPDATE FileEntity SET DateDeleted = GETDATE() WHERE ID IN (1,2,3) I've come to both love and hate LINQ, but so far there's been little that hasn't worked out well. The obvious solution which I want to avoid is to enumerate all file entities and set them manua...

Can't bind a GridView to a LINQ to SQL Result

OK, I am amittedly new to LINQ and have spent the last week reading everything I could on it. I am just playing around, trying to follow some examples I have found (a PDF from Scott Gu on the topic, in fact) and I am at a complete loss. Can someone please tell me why, when I bind a GridView to the query below, using the code below, I g...

Has a month gone by?

In my database I have a table holding some subscription information. I have among others a StartDate and an EndDate as DateTime. What I need is to make a Linq query getting all rows due for payment. The payment is supposed to take place each month on the same day they registered (StartDate) and stop on the EndDate. So if they registered...

JOIN with LinqtoSql, only select TOP(x) on joined table?

I've had a look around on StackOverlow but haven't been able to find a definitive answer on this. Below I have a code snippet of what I currently have, and I will explain what I am trying to achieve. Table<Gallery> galleries = pdc.GetTable<Gallery>(); Table<GalleryImage> images = pdc.GetTable<GalleryImage>(); Table<Comment> comments = ...