linq-to-sql

Best practice: Creating ORM objects at runtime by scheme stored in DB

Hi! At my current project(huge enterprise system) I'm faced to scenario when "simple" objects like table, reference list are created at runtime via system info stored in the same DB(special sys tables). Users can create those simple objects and relations between them. The complicated objects are created by developers. For the first case ...

LINQ to SQL Binary data in chunks?

I have a ASP.net MVC webpage, that has a custom document repository in it. The document are stored in a Sql Server 2008 Filestream Filegroup. I am using LINQ to SQL to access the database, then doing a Response.BinaryWrite() to download the file. This works fine, except when the file is big. If the file is big, I am getting a System ...

Migrating from LINQ to SQL to Entity Framework 4.0 - Tips, Documentation, etc.

I tried out EF back in .NET 3.5 SP1, and I was one of the many who got frustrated and decided to learn LINQ to SQL instead. Now that I know EF is the "chosen" path forward, plus EF 4.0 has some exciting new features, I'd like to migrate my app to EF 4.0. Can anyone suggest any good resources that are specifically targeted towards 4.0 a...

LINQ-to-SQL with SQLite: syntax error near "SELECT" when inserting

I have been using the System.Data.SQLite provider for my application. When I try to create a new object and insert it into the database, however, I get a SQL syntax error near "SELECT". Basically my code looks like: //supplies is a DataContext connected to my DB Table<Store> stores = supplies.Stores; //... Store newStore = new Store();...

Should Linq to SQL repository implement IDisposable

I've been googling a ton on repository patterns with Linq over the last few days. There's a lot of info out there but it's often contradictory and I'm still looking for a definitive source. One of the things I'm still not sure about is whether the repository should instantiate it's own DataContext and have a SubmitChanges method, or if ...

LINQ to SQL association throwing null exception

Hello! I have a Person class being generated by LINQ to SQL, which has a Rota association property to a Rota class. However when trying to access the Rota property on Person (for instance calling db.People.First().Rota), a NullReferenceException in thrown in the generated LINQ to SQL class's property: get { r...

LINQ to SQL or Entities, at this point?

I'm a bit late to the game and have decided to spend some spare time learning LINQ. As an exercise, I'm going to rewrite a WebForms app in MVC 2 (which is also new to me). I managed to find a few topics regarding LINQ here (http://stackoverflow.com/questions/16322/learning-about-linq, http://stackoverflow.com/questions/8050/beginners-gui...

Linq to SQL and Realtime Data

I have an application that needs to constantly (every 50ms), call to an MVC action, and pickup/drop off data. I am using Linq to SQL and MVC because of how simple they are to implement, and I know that they aren't perfect when it comes to performance, but it works relatively well, but the best speed I can get with my current approach is...

Where do objects merge/join data in a 3-tier model?

Its probarbly a simple 3-tier problem. I just want to make sure we use the best practice for this and I am not that familiary with the structures yet. We have the 3 tiers: GUI: ASP.NET for Presentation-layer (first platform) BAL: Business-layer will be handling the logic on a webserver in C#, so we both can use it for webforms/MVC + w...

Exception with Linq2SQL Query

I am running a query using Linq2SQL that comes down to following query: DateTime? expiration = GetExpirationDate(); IQueryable<Persons> persons = GetPersons(); IQueryable<Items> subquery = from i in db.Items where i.ExpirationDate >= expiration select i; return persons.Where(...

how to write Linq2Sql statement to sort several column in cascading way?

Hello, I've 3 columns that I'd like to sort in the Excel way, i.e. sorting the first column, and for each element sorted in the first column, I'll sort the second column, and so on. Let's say I first sort alphabeticaly Countries, then for each country, I sort alphabeticaly cities. How do I do it using Linq2Sql? Thanks for helping ...

How can I compare two sets of data in linq and return the common data?

I have two IList<string> a and b. I want to find out what strings are in both a and b using LINQ. ...

How To Query Many-to-Many Table (one table's values becomes column headers)

Given this table structure, I want to flatten out the many-to-many relationships and make the values in the Name field of one table into column headers and the quantities from the same table into column values. The current idea which will work is to put the values into a Dictionary (hashtable) and represent this data in code but im wond...

LinQ: Add list to a list

I have the following code: var columnNames = (from autoExport in dataContext.AutoExports where autoExport.AutoExportTemplate != null && ContainsColumn(autoExport.AutoExportTemplate, realName) select GetDbColumnNames(autoExport.AutoExportTemplate, realName)).ToList(); Where the function G...

Linq-To-Sql - Portability Problem

I've created an ASP.NET solution on my computer. There is a business layer in the project, which uses Linq-To-Sql for Database operations. How can I open the same project on another computer? I am having problems, becuse of connection string or etc. ...

LINQ To SQL Dynamic Select

Can someone show me how to indicate which columns I would like returned at run-time from a LINQ To SQL statement? I am allowing the user to select items in a checkboxlist representing the columns they would like displayed in a gridview that is bound to the results of a L2S query. I am able to dynamically generate the WHERE clause but a...

Linq to SQL - Invalid attempt to call FieldCount when reader is closed

Has anyone seen this error before when making a Linq to SQL call? Invalid attempt to call FieldCount when reader is closed Here's the code: public static MM GetDeviceConfiguration(long ipAddress) { string sprocName = ConfigurationBL.ReadSproc("ReadDeviceConfiguration"); return db.ExecuteQuery<MM>("exec {0} @IPAddressNumber = {...

Business Hours of Operation in SQL/C#

I am having a massive brain fart on this one for some reason. I have a table with "Hours of Operation" for a business. The table has: - Day (Monday = 1, Sunday = 7) - Start Time - End Time I'm trying to figure out how to write the cleanest code (using Linq to SQL) that will check if hours are overlapping on submit of new hours and modif...

LINQ to SQL SOUNDEX - possible?

Hello, I have done a little bit of research on this and looked through a few articles both here on StackOverflow as well as some blog posts, but haven't found an exact answer. I also read that it is possible to do it using the 4.0 framework, but have yet to find any supporting evidence. So my question, is it possible to perform SOUNDEX...

How can you exclude a large number of records in a cross db query using LINQ2SQL?

So here is my situation: I have a vendor supplied DB we cannot modify and a custom db that imports data from the vendor app and acts on it. Once records are imported form the vendor app, they cannot appear on the list of records to be imported. Also we only want to display the 250 most recent records that have not been imported. What I ...