linq-to-sql

Is this the correct usage of the ViewModel Pattern?

I'm using NerdDinner as a guide for my first MVC/LINQ to SQL project. It discusses the use of the ViewModel pattern when a View needs data from multiple sources - in their example: Dinners and Countries (serves as the drop down list). In my application, the problem is a bit different. It's not so much different data, rather data linke...

LINQ to SQL lambda exp. OrderBy, Case When

Hi guys! Going to need your help on this one. I'm trying to OrderBy first reply datetime if present. If it's empty/null, it must order by topic datetime. I've ended up with the following expression, but it just doesn't seem to work :( return db.Topics .Where(t => t.ForumID == id) .OrderBy( t => t.Replies .OrderBy(r => r.AddDat...

How to alter this LINQ to SQL so it doesn't bomb at runtime?

public IQueryable<Story> FindAllStories(){ var stories = (from s in db.Stories orderby s.DateEntered descending select new Story { Title = s.Title, UserName = s.aspnet_User.UserName ...

how to get next and previous record id using linq to sql?

var product = db.Products.First(p => p.Id == 5); In the product detail show page, show.aspx?Id=5, I want to get the previous and next product link. How can I do that? Should I connect to the database three times to get the current product and previous id and next id for generate links? ...

[.NET] How to talk to a database in a portable way?

I'd like to start an application that makes heavy use of a database, and is supposed to run on Windows under .NET as well as Mac/Linux under Mono. Having done some research, I've realised that neither LINQ-to-SQL nor LINQ-to-Entities are production-ready in Mono at the moment (here and here). According to the former link, LINQ-to-SQL ma...

Is there a fast way to get rows from a table by range as IQueryable in C# LINQ to SQL?

like say I want to make a method in my repository like public IQueryable<Item> GetAllItemsByRange(int start, int end) and then I just want to pass like (1, 100), (101, 200), (201, 300), etc so I can get back ONLY that range without having to get EVERYTHING at once thanks! ...

For argument's sake, how will i convince someone that Linq2Sql is far better than Data Access Application Block in an Asp.Net MVC project?

How will i convince someone that Linq2Sql is far better than Data Access Application Block in an Asp.Net MVC project? ...

Is Linq to SQL still a valid option?

I'm looking at starting a new project and one of the requirements I've been given is that the data mapping must have a very easy learning curve. Linq to SQL seems as straight forward as it comes. However, I'm getting confused signals from different sources about the project being killed. Some say it's dead, some say it's now part of the ...

[LINQ-to-SQL] Does SQL Server Compact (CE) support a RequiresNew transaction scope inside another one?

Here's a very simple example using SQL Server CE 3.5 SP1 where I attempt to use a new transaction inside an existing one. using (var db = new MyDataContext(<connection string>)) using (var ts = new TransactionScope()) { db.Thing.InsertOnSubmit(new Thing()); db.SubmitChanges(); using (var ts2 = new TransactionScope(Transactio...

LINQ to SQL Cannot create database [Schema Permissions]

For some integration tests I want to use LINQ to SQL to drop/re-create the test database. I've had this working fine before, however in this project the database is split up into several schemas. When I try to run the ctx.CreateDatabase() command I'm getting this exception: The specified schema name "xyz" either does not exist or...

VB.Net Linq To SQL Sub Select

Hello, I have the following query which groups some records and then filters where the count of the grouped records is 1. I'd like to take the returned result and perform another query to retrieve the entire record from the JobcodesWorkingRollup table where the ParentNode column equals the result of this query: Dim query = From...

Linq: Sum of int

I am getting "The null value cannot be assigned to a member with type System.Int32 which is a non-nullable value type" When executing Sum() of my empty statement. ResultView works fine, but either var r = from v in DataContext.Visits join bs in DataContext.BaseContents on v.BaseContentID equals bs.Id where (bs.CreatedBy ...

How should I work with SQL Timestamps in a WebForms / Linq To SQL project?

I have a WebForms project where we are using Linq to SQL (L2S) to provide data access. I know L2S can handle timestamps, but what I'm wondering is, what is the best way to handle timestamps at the client side. I'm thinking that one possibility is to simply put the timestamp into a hidden field when an entity is rendered, but this feels ...

Linq query help

I'm attempting to write a linq query which uses several tables of related data and have gotten stuck. The expected result: I need to return the three most populous metropolitan areas per region by population descending. tables w/sample data: MetroAreas -- ID, Name 2, Greater New York Cities -- ID, Name, StateID 1293912, New York City...

Reference Required for Assembly that is definitely part of a project

I have a project that I am in the process of migrating to using Linq To SQL. On the whole it's fine, but I'm stuck on an issue where if I try to put a timestamp from an DTO into a hidden field I get this error at runtime: BC30652: Reference required to assembly 'System.Data.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5...

LINQ vs. presentation model

Does LINQ substitute the presentation model? I read in the book "ASP.NET MVC in Action" about presentation models. I wonder why to build a presentation model?! For instance, projecting a domain object (entity) by creating a new class at runtime via LINQ is in my opinion more comfortable than creating dozens of presentation objects. ...

ASP.NET search form - dynamic Linq to SQL?

I have a search form that allows users to search on several different fields in several different ways. Here is an example of my code. var claims = from c in db.Claims select c; switch (ddlSearchField.Text) { case "StartsWith": claims = claims.Where(c => c.companyFileID.StartsWith(txtSearchBox.Text)); break; ca...

LINQ to SQL for Oracle.ODP

Does LINQ to SQL support Oracle.ODP? If not, is a similar offering from Oracle available or in the works? ...

In terms of performance, which is faster: Linq2SQL or Linq2Entities (in ASP.net MVC)

Comparing the two data models in an asp.net MVC app, which provides better performance, LINQ 2 SQL or LINQ 2 Entities. They don't always perform the same database operations when you use the same methods, or have the same LINQ methods for that matter.... ...

Combine multiple objects for insert into one table using Linq

I want to insert into one table from the properties of multiple classes using Linq. Here are some representations of my objects( I am custom creating my Linq Objects with the attributes): <Table(Name:="Certificates")> _ Public Class Certificate : Implements ICertificate, INotifyPropertyChanged <Column(CanBeNull:=False, IsDbGenerated...