My Title may be slightly off but here is what I am trying to do. I have a L2S Method that would be for every table that I would like to write once. This is to set a soft lock column where I will also need a Read and UnLock method. Here is what I have so far:
public static void LockRow(string TableName, int TablePrimaryKey)
{
...
I have a long LinqtoSQl query in which several parameters I'm not forcing the user to specify anything. I started using a Select Case statement that would test rather or not a parameter string's length > 0 or if it's an int > 0. But I realized that I would have to test for each possibility and create queries based on each.
I did some se...
I am moving an old ASP.net (C#) application from plain SQL queries to LINQ to SQL and am having some trouble with some of the more complex queries. In this case, I am trying to get a list of employees who have a certain set of skills. The user picks the skills to search for and the id's are supplied to the method that does the work. In t...
I am developing sample web application which use C#, and LINQ to SQL. The application is very very slow and it takes about 2 secs to navigate between pages. I have already used SQL Profiler and monitor the calls to the SQL server. All SQLs looks normal to me and their execution time is always about 1 or 2 millisecs.
I tried the same ...
I am trying to teach myself LINQ to SQL and have decided to do a small MVC.NET project to get my feet wet. The problem is that I have fallen very early on with the following error.
I am making a golf application so I have setup the database and got my dbml classes made. The database has a course table and a hole table. The hole table re...
First I want to pre-thank anyone who helps with this.
Back when I was programming in Linq-to-Sql there was a per-property option for deferred loading which was perfect for excluding large binary fields in a table without actually having to write special select statements to exclude each one. I can re-architect the database to make the b...
I found a bunch of possible duplicates around this but none really seemed to be having the same problem I'm having.
I'm getting a DuplicateKeyException: Cannot add an entity with a key that is already in use. Here's my SqlProductsRepository:
public class SqlProductsRepository : IProductsRepository
{
private Table<Product> productsT...
i have this in my query:
var results = (from urls in _context.Urls
join documents in _context.Documents on urls.UrlId equals documents.DocumentId
let words = (from words in _context.Words
join hits in _context.Hits on words.WordId equals hits.WordId
wh...
Hi, I'm developing a very basic web search engine that has several parts. After retrieving results according to a user query, I want to calculate rate of each result and then sort results by calculated rate. Here is my query:
var tmpQuery = (from urls in _context.Urls
join documents in _context.Documents
...
I'm a complete newbie to LINQ, so please bare with my stupid questions.
Using Visual Studio I've created a DBML file, and added a table to it from a local database. This created a data context called UserDataContext. In my ASPX page I can create an instance of the data context using:
UserDataContext db1 = new UserDataContext();
Howev...
Hi,
anybody have any easy way of doing this in Visual Studio, without having to use the Server Explorer ?
I tried also looking at macro's but recording only produce
Sub TemporaryMacro()
End Sub
So no luck there.
Any way to script this?
...
Hi all,
I am using c# \ .net 3.5 and linqtosql (over an sql server dbms of course).
I am using my data context for automic operations.
I have a GetReadonly method of a factory method that returns me a new datacontext for each atomic operation.
I am able to perform CRUD operations well, though the following error occurs:
When I update ...
Hi,
Since IEnumerable.Contains() method does not accept a predicate as an argument, Most people use the following code to check the existence of something matching a condition:
// ProductId is unique.
if (Products.Count(c => c.ProductId = 1234) == 1)
{
// Products list contains product 1234.
}
This code forces to walk through eve...
The situation I am in is that I have a set of existing tables with incrementing Integers as Ids. I have now added a GUID to each table to be the new PK.
I have a primary table
dbo.ParentTable(GUID - PK, ParentTableId INT, Name VARHCHAR)
and a child table
dbo.ChildTable(GUID - PK, ParentTableId INT, other fields.....)
and want ...
I have done some searching around but have not been able to figure out how to bind LinqToSql data context's with specified connection strings into different repositories.
This binding is performed in global.ajax when routes are registered. I'm using a fairly standard repository pattern to decouple the LinqToSql infrastructure from my ap...
I am developing application VS 2008, .NET 3.5 and I am trying to use LINQ To SQL. I drag & drop tables on the designer to generate the .dbml file.
The problem I have that I have some dynamic tables for search indexing.
I know the structure of table, only the application creates new tables like this:
Files_1_1, Files_1_2, ... Files_m_...
In the book I'm reading "Pro Linq in C# 2010" (APress, Freeman and Ratz) the author states that IQueryable will only be returned from the classes in the Linq to Sql namespace, not in the general Linq namespace. I was surprised by this, since I thought anything that had a Where on the end had to be IQueryable. Turns out I was wrong, Where...
I know that you can return multiple results from a stored procedure and through the method generated by the designer.
However, I'm trying to do the same using ExecuteQuery but it doesn't seem like it's possible.
Has anyone tried or know whether this is possible?
Basically I'm trying to run an ad-hoc stored procedure. By ad-hoc, I mean...
I'm pretty new to Linq to SQL & Linq to XML but have cobbled together some code together that put the XML results from a stored proc into an XElement. However, it's started failing, apparently now that the XML data is getting larger (2K+) and my .Parse is reading truncated XML (the XML data comes back in two rows). Before i start fumblin...
I am new to LINQ. I am using Visual Studio 2008 and have created a "LINQ to SQL Classes" (.dbml) file in my project. I've added each of my database tables to the design view and everything works fine.
My question is this: When a change to a table's design has been made in the database, i.e. fields added, how do you update the class...