linq-to-sql

Can I put a constraint on a sql server table to not allow empty string?

I'm getting this error Linq to Sql Error - "String must be exactly one character long" Is it possible to put a constraint on a nullable varchar(1) field to allow null but not allow an empty string? ...

Linq entities created at runtime from user-defined view

Hello, I would like to use linq2sql in this scenario : I have a user-defined view in my database whose fields are not known during the design phase. How can I create a specific entity, during runtime, to use a gridview to show all the view's fields ? ...

Is there any tool to see the queries run against the database?

Is there any tool that will inspect either asp.net or sql server and report all the queries that are run against the database? The reason I ask is I am using Linq for a project and want to double check what its actually doing for each page. Ideally I'd like to view a page in a browser and have a report of all the queries that were ru...

Is this an invalid linq-to-sql detached design?

Consider the following: I have a high level component that deals with detached Linq to Sql entities. We'll call them Foo and Prop, where a single Foo may be associated with many Prop, but every Prop is always associated with exactly one Foo. So: +------+ 1 0..n +------+ | Foo |-----------| Prop | +------+ +------+ Ver...

Can I execute a LINQ to SQL query from within a LINQ object?

I currently have a LINQ query implemented as a method of my DataContext class. This method calculates the permissions a user has for a page within a Wiki/CMS. What I'd like to do is relocate this method to the Page and User LINQ data objects. However, when I move this query to the individual data objects it executes using LINQ to Obje...

Has anyone used Huagati DBML Tools ? I wanted to get some hands on feedback.

http://www.huagati.com/dbmltools/ ...

Winforms Application Architecture using LinqToSql

Hi there. I am starting a new Winforms application, and I've always used traditional ADO.NET methods in my DAL (...yes, hardcoding!) I have used Linq on many ocassions previously, but more for adhoc queries, so I have some experience with it and I loved how easy it was to write querying code. What I would like to perhaps do is replace ...

Linq to SQL SP parameters

I have a SP which I want to call from linq. The SP have 5 parameters but i only want to pass/need to 2 of them. how would I call the SP as when i go to add the parameters in code it wont build as it want all 5. ...

Linq not inserting record for the middle many-to-many relationship table.

I am having creating a new record that will be inserted into the DB. I looked at the db.log but nothing gets printed. I have primary keys marked, but not sure what else needs to be done. Have a many-to-many relationship between two tables (Member and RecForms). This is being down through a middle table of MemberRecForms that contains...

Linq to SQL with Group by

I am trying to convert this T-SQL to a Linq To SQL but can't work out the group by aggregate functions. Any help welcome. select c.ClientID, GivenName, Surname, max(a.Address), max(t.Value) from Client c left join ClientAddress a on c.ClientID = a.ClientID left join ClientContact t on c.ClientID = t.ClientID group by c.ClientID, GivenNa...

escape apostrophes in Linq based stored procedure calls when SP contains dynamic SQL

Hi guys, I noticed the following: An ASP.NET MVC website under development gets an SQL error "Unclosed quotation mark ..." when it makes a LINQ call to a stored procedure that contains dynamic SQL. For example: SP GetEmployees called with parameter [filter_name] that has value [n'for] throws this error I can fix the problem by doing...

Comparison operators not supported for type 'System.String[]'

why this line: var category = _dataContext.Categories.Where<Category>(p => p.Keywords.Split(' ').Contains<string>(context.Request.QueryString["q"])).First(); throws an System.NotSupportedException: Comparison operators not supported for type 'System.String[]' And how can I fix it? Thanks. ...

Add column to the database - how do i update the dbml file

is there a way i can refresh the dbml file or do i have to delete it and generate a whole new one? ...

Validate Linq2Sql before SubmitChanges()

Can anyone tell me if/how you can validate the changes in a data context in Linq2Sql before calling SubmitChanges(). The situation I have is that I create a context, perform multiple operations and add many inserts alongside other processing tasks and then rollback if the submit fails. What I'd prefer to do is make some kind of "Valida...

What is the best way in WPF/Silverlight for simple dropdown that displays appropriate data?

Below is a simple WPF application which displays Customers with the most orders which is collected from the database via LINQ-to-SQL in the code-behind. What is the best way to extend this WPF application so that the user can select from a dropdown, e.g.: Customers with the most orders Customers with the least orders Customers by city...

LINQ Where() Single or Double Pipes / Ampersands

Anyone care to comment on whether we should be using "I" or "II" and "&" or "&&" in our LINQ Where() extensions / queries? Any difference with LINQ to SQL? The resulting expression tree is more than I can get my brain around on a Friday afternoon Thanks, static void Main(string[] args) { var numbers = new int[] { 1, 2, 3, 4, 5, 6, ...

ASP.NET MVC - model decision: how to design it?

This is concerning an enterprise application with a very generic database (all objects are identified using data in the database and internationalized/globalized/localized). Make a model for Repository pattern, then make (generate 1:1) another model for DB access (LINQ2SQL or EF) and use the later as repository model data access layer?...

When do LINQ-to-SQL queries execute?

I just want to confirm... LINQ-to-SQL queries never execute (hits the database) until it is enumerated, right? Does anyone know if this is the same for LINQ-to-Entities? Thanks! ...

Binding for an EntitySet is displaying values that aren't there?

I'm binding an ItemsControl to an EntitySet in a WPF application. Its not acting as expected, however. The ItemsControl is behaving as if it is caching the contents of the EntitySet between binds! Here's the stripped down code: The entity: public partial class Item : INotifyPropertyChanging, INotifyPropertyChanged { private Enti...

Visual studio C# Linq bulk insert/update

Hi, I have recently developed a C# application using Linq. I am getting from an external database a list of profiles I need to process, some are new and some are already in the database, and need to be updated. What I do today is go over the profile list and check each profile if such exists I update otherwise I insert - this solution is...