linq-to-sql

How can I combine these linq queries into one?

Being new to LINQ, I created a couple queries and would like to combine them into one, but I am not sure how to do it. Here they are: var u = dc.Users.Where(w => w.UserName == userName).SingleOrDefault(); var m = dc.Memberships.Where(w => w.UserId == u.UserId).SingleOrDefault(); m.PasswordQuestion = securityQuestion; m.PasswordAnswer...

Is there anyway to serilize linq object for Memcached?

I'm just start switching to memcached and currently on testing with memcached. I'm having 2 object, I created an object and put [Serializable] on it (for instance, let call this Object1), the other object is created using Linq DBML (Object2).. I tried to memcached List<Object1>, it work just fine, like charm, everything here is cache ...

IQueryable to DataSet

I have seen numerous methods and tricks around the net today. What i need is convert my Linq to SQL queries (IQueryable results) into a DataSet for reporting purposes. Reporting tool is XtraReports from DevExpress. A promising solution i found in another post is modelshredder. I am still concern though about the whole object graph, what...

How to define a return List<T> for a LinqToSql Join?

I use Linq To Sql Join Query in DAL layer, How can I define a return List<T> automatically for the LinqToSql Join method? Nowadays, I have to manually define a List<CustomViewType> for each LinqToSql Join method's return value. Is that possible to define a List<T> like the following code : public static List<T> GetJoinList() { L...

What do you recomend for distributed cache linq to sql object?

http://stackoverflow.com/questions/2122081/is-there-anyway-to-serilize-linq-object-for-memcached I asked a question previously here, but really no one help out on this. I was wondering is there anyway to cache linq to sql object... like List or something similar, where there are hierachy... I tried most Wraper for memcached and it does ...

Multi-threading access to SubmitChanges() (LINQ to SQL)

I am using Visual Studio 2010 Beta 2. In Parallel.For loop I execute the same method with different parameter values. After execution processed data must be stored in the database. But I've got an exception hat says that I could not work with the same data context from different threads. So the question will be how to work with dat...

Feasibility of entity framework and linq to sql

Is it worth spending time in these frameworks. Or they just another framework like microsoft developed in the form of MFC library. I dont want to waste precious time, so please help. Under what scenarios these frameworks will be helpful. ...

LINQ: Stop lazy loading or force properties to be loaded

Consider a report in Windows forms which uses Linq to Objects as a datasource. I have an entity named Loan with an association named Customer. The problem is that when I try to access the .Customer property in a report, it returns null or empty string. I suppose this is because of lazy loading but I'm not sure to be honest. Is there a ...

How to get the sql update method generated by LinqToSql?

How to get the sql generated by LinqToSql for update method? I use the following code to show the sql generated by LinqToSql in VS2008's debug output window, but it only gets the sql select method generated, how can I find the sql update method that was generated by LinqToSql? I know the Sql Server Profiler and LinqPad can get it(th...

Databinding of WPF Toolkit DataGrid to LINQ to SQL queries

When binding WPF Toolkit DataGrid to SQL database through LINQ to SQL, how to correctly set binding source: should it be some generic collection, filled and updated by LINQ to SQL queries or there is a possibility to directly connect DataGrid with LINQ to SQL queries? ...

Linq-To-SQL Check existance of a record before returning resultset.

I'm looking for a simple solution to replace my standardized junk way of validating whether a record exists before attempting to retrieve the data. Currently, whenever one of my methods are called, I do something to the effect of... private Record DoSomething(int id) { if(data.Records.Count(q=>q.Id==id) > 0) { return data.R...

LINQ-To-SQL Business-Layer Object DataContext

Originally, I was using my DataContext object as a global singleton. When using this in ASP.Net, I was running into issues with contention because of the multi-threaded nature of ASP.Net. So I did some searching for better alternatives, and found Rick Strahl's post about "per object" scenario. So each of my objects would have a DataCo...

Problem attaching to a sql server express db file using network service account

I am using VS2010 Beta 2 to create an IIS hosted WCF service. I added a SQL Server database file to use as a simple data store and then generated some Linq to SQL classes to interact with it. The problem I have happens when Linq to SQL tries to connect to the database. I get the following error below: CREATE DATABASE permission denied ...

Best approach for a Binary column with LINQ to SQL

My SQL 2008 table, let's call it tblDocument, has columns like name, creator, sequenceNumber, followed by a "DocumentContent" varbinary(max) column that contains the document itself. I'm using LINQ to SQL. If I want to display the rows of tblDocument in an interface without retrieving a multi-megabyte binary over the wire for each row,...

Perform conditional bulk update in Linq to SQL

I have a SQL table that stores photos with a smallint SortOrder field. Users can insert new photos, specifying a decimal sort order to place the new record between 2 existing photos (or before the first photo). The SortOrder will be stored as a smallint, so when I detect that an insertion will shift existing records, I need to update a...

What is "Audit Logout" in SQL Server Profiler?

I'm running a data import (using C#/Linq), and naturally I'm trying to optimize my queries as much as possible. To this end I'm running a trace on the DB using SQL Server Profiler, with my trace filtered by my SQL login name (it's a name that can uniquely be attributed to my data import process). Strangely enough, most of my SQL statem...

Posting complex LINQ-to-SQL object to ASP.NET MVC Controller

I'm able to post a complex object to an ASP.NET MVC controller with jQuery, as long as I modify the output of $.param() like this: "Column[0][Name]" -> "Column[0].Name" However, this only works if the data is bound to an array-type property on the server (Columns1 in the example below). A collection type like IEnumerable or the EntityS...

system.linq.dynamic: building a dynamic projection

I apologize in advance for not being able to give a code sample. It would be problematic and not quite clear but the pseudo below may suffice. What I'm attempting to do is construct a dynamic projection leveraging system.linq.dynamic. I'm, at times, asking LinqToSql to do some magic and asking for properties in a related entity by usi...

Null value being returned from a Stored Procedure using Linq to SQL

If I run a stored procedure in my database (SQL 2000) and return the SCOPE_IDENTITY, I receive a value. However, using LINQ to SQL, I get a null value for the Column1 property. Anyone have a suggestion? ...

Linq to SQL Audit Trail / Audit Log: should I use triggers or doddleaudit?

Hi, I'm working on a business app that requires that ALL database transactions be audited (for legal purposes mainly). I've looked around the web and came across DoddleAudit (http://www.codeplex.com/DoddleAudit) which basically adds the ability for Linq to SQL to track the changes. Much like people use Interceptors in Hibernate. The th...