linq-to-sql

GridView will not update underlying data source

So I'm been pounding on this problem all day. I've got a LinqDataSource that points to my model and a GridView that consumes it. When I attempt to do an update on the GridView, it does not update the underlying data source. I thought it might have to do with the LinqDataSource, so I added a SqlDataSource and the same thing happens. The a...

How are people unit testing code that uses Linq to SQL

How are people unit testing code that uses Linq to SQL? ...

In LINQ to SQL how can I make it so I can add items to a collection of an entity without saving the entity first?

var e1 = new E1(); e1.e2s.Add(new e2()); //e2s is null until e1 is saved, i want to save them all at the same time context.e1s.imsertonsubmit(e1); context.submitchanges(); ...

linq to sql stack overflow with self-referencing entity

I have an entity that contains many of itself, how do I map this in LINQ to SQl such that it does not do an infinite loop of getting e1 then all its children then their parents (e1) then its children and repeat? Now I know I can do this if I set the child property to false, however that is the most important property (don't really care a...

NHibernate or LINQ to SQL

If starting a new project what would you use for your ORM NHibernate or LINQ and why. What are the pros and cons of each. edit: LINQ to SQL not just LINQ (thanks @Jon Limjap) ...

Can a Linq query retrieve BLOBs from a Sql Database?

And how do they come out? ...

Linq to SQL - Accessing System Databases/Tables?

Right now I have an SSIS package that runs every morning and gives me a report on the number of packages that failed or succeeded from the day before. The information for these packages is contained partly within the sysjobs table (a system table) within the msdb database (a system database) in SQL Server 2005. When trying to move the ...

How would you refactor this LINQ code?

I've got a lot of ugly code that looks like this: if (!string.IsNullOrEmpty(ddlFileName.SelectedItem.Text)) results = results.Where(x => x.FileName.Contains(ddlFileName.SelectedValue)); if (chkFileName.Checked) results = results.Where(x => x.FileName == null); if (!string.IsNullOrEmpty(ddlIPAddress.SelectedItem.Text)) resul...

How do you perform a CROSS JOIN with LINQ to SQL?

How do you perform a CROSS JOIN with LINQ to SQL? ...

Which is the best database schema for my navigation?

I'm creating a web site where all pages hang off a database-driven tree-hierarchy. All but one node has a parent node. Nodes may have role-based read permissions. Some nodes may have special rules (such as: don't display within navigation menus). Nodes may represent links to other nodes (like a shortcut in Windows). Nodes typically ...

What's the best way to handle one-to-one relationships in SQL?

Let's say I've got Alpha things that may or may not be or be related to Bravo or Charlie things. These are one-to-one relationships: No Alpha will relate to more than one Bravo. And no Bravo will relate to more than one Alpha. I've got a few goals: a system that's easy to learn and maintain. data integrity enforced within my databas...

ASP.NET Convert Invalid String to Null

In my application I have TextBox in a FormView bound to a LinqDataSource like so: <asp:TextBox ID="MyTextBox" runat="server" Text='<%# Bind("MyValue") %>' AutoPostBack="True" ontextchanged="MyTextBox_TextChanged" /> protected void MyTextBox_TextChanged(object sender, EventArgs e) { MyFormView.UpdateItem(...

How do you extend Linq to SQL?

Last year, Scott Guthrie stated “You can actually override the raw SQL that LINQ to SQL uses if you want absolute control over the SQL executed”, but I can’t find documentation describing an extensibility method. I would like to modify the following LINQ to SQL query: using (NorthwindContext northwind = new NorthwindContext ()) { v...

.NET 3.5 Linq Datasource and Joins

Have been trying out the new Dynamic Data site create tool that shipped with .NET 3.5. The tool uses LINQ Datasources to get the data from the database using a .dmbl context file for a reference. I am interseted in customizing a data grid but I need to show data from more than one table. Does anyone know how to do this using the LINQ D...

Can a LINQ to SQL IsDiscriminator column NOT inherit?

I'm designing my database and LINQ To SQL ASP.NET web application. Imagine I have two types of pages: normal and root. Some pages are roots. Some pages are not. I have a Page database table and a RootPage database table: Page ---- PK PageId HtmlTitle PageHeading MetaDescription IsRoot R...

LinqToSql and full text search - can it be done?

Has anyone come up with a good way of performing full text searches (FREETEXT() CONTAINS()) for any number of arbitrary keywords using standard LinqToSql query syntax? I'd obviously like to avoid having to use a Stored Proc or have to generate a Dynamic SQL calls. Obviously I could just pump the search string in on a parameter to a SPR...

When choosing an ORM, is LINQ to SQL or LINQ to Entities better than NHibernate?

I find I can do more with NHibernate, and even Castle than with the Linq to Entities, or linq to SQL. Am I crazy? ...

Does LINQ To SQL provide faster response times than using ado.net and oledb?

LINQ simplifies database programming no doubt, but does it have a downside? Inline SQL requires one to communicate with the database in a certain way that opens the database to injections. Inline SQL must also be syntax-checked, have a plan built, and then executed, which takes precious cycles. Stored procedures have also been a rock-...

When using Linq to SQL with stored procedures, must char(1) columns be returned as c# chars?

When using Linq to SQL and stored procedures, the class generated to describe the proc's result set uses char properties to represent char(1) columns in the SQL proc. I'd rather these be strings - is there any easy way to make this happen? ...

Good way to time SQL queries when using Linq to SQL

Is there a good way to time SQL queries when using Linq to SQL? I really like logging feature, but it would be great if you could somehow also time that query. Any ideas? ...