linq-to-sql

Setting up the Business Logic Layer with a DBML

I'm busy on making a Business Logic Layer. Now I had a problem since i want to program using c# and the whole project i have to make a module for is vb.net based. I have solved this using a new project in the solution. This project will maintain the dataclasses and Business Logic. Now i've run to an issue, atleast i don't know what to do...

Add the origin connectionString to Linq2Sql entities.

Hi, I have a ASP.NET web application that use the same DataContextType to access several Databases with the same schema. A problem I have is that I'd like to reference the origin Database of entities by adding to them a property (e.g. a ConnectionString property) and auto assign it on entity creation. I though it could be done easily...

How to perform a select using a WHERE NOT EXISTS

I'm using LINQ2SQL and I want to compare two tables and select all rows that are missing from one tables (based upon one of the column values). In standard SQL I would write this as: SELECT FirstName, LastName, RefId, Email FROM Users_ActiveDirectory AS ADU WHERE NOT EXISTS ( SELECT U.RefId FROM Users AS U WHERE U.RefID = ADU.RefId )...

LINQ to SQL doesn't return data, but the generated SQL statement does

I have a LINQ to SQL query that when executed does not return any data. However, when I debug, I can take the generated SQL query, plug in the values for the variables, and run it in SQL Management Studio to get the record I'm expecting. I'm taking the values for the variables while in debug mode as well. Has anyone experienced someth...

Should you use storeded procedures in linq to sql?

Does someone out there use stored procedures with linq to sql and why? Should we use them? Their support is there in linq to sql. I am asking because I use to use it before my recent application. ...

Sync LINQ-to-SQL DBML schema with SQL Server database

After creating a SQL Server 2008 database, I made a Linq-to-SQL schema in Visual Studio. Next, in the .dbml visual editor (in Visual Studio 2010), I added PK-to-FK and PK-to-PK associations to the schema. How do I copy those associations that I created in Visual Studio over to the database? In other words, how do I sync with the DB? ...

LINQ to SQL Queries odd Materialization

I ran across an interesting Linq to SQL, uh, feature, the other day. Perhaps someone can give me a logical explanation for the reasoning behind the results. Take the code below as my example which utilizes the AdventureWorks database setup in a Linq to SQL DataContext. This is a clip from my unit test. The resulting customer returned fro...

Convert this SQL statement to LINQ-to-SQL

I have struggled converting this SQL statement to LINQ to SQL VB.Net 9.0. I have used Linqer but no success. Any help would be appreciated select t.TeeId, t.DescriptionId, t.[Description], t.Rating, t.Slope, case when d.TotalHoles <> h.TotalHoles then 0 else 1 end [Status] from dbo.CourseDescription d inner join dbo.Co...

How can I combine a LINQ query with an IQueryable<Guid>

I have a LINQ query that uses 1 table + a large number of views. I'd like to be able to write something like this: IQueryable<Guid> mostViewedWriters; switch (datePicker) { case DatePicker.Last12Hours: mostViewedWriters = from x in context.tempMostViewed12Hours select x.GuidId; break; ...

LINQ to SQL: ExecuteQuery not working when performing a parameterized query.

I have a weird problem with ExecuteQuery in that it isn't working when performing a parameterized query. The following returns 1 record: db.ExecuteQuery<Member>(@"SELECT * FROM Member INNER JOIN aspnet_Users ON Member.user_id = aspnet_Users.UserId WHERE [asp...

how to implement join in linq to sql query

how to implement join in linq to sql query ...

LINQ Multiple LIKE based on List

I have a list of keywords in an ArrayList and I wanted to be able to build a query to find records in a table based on this keywords. Since the list of keywords is dynamic I cannot build a fixed query here. I do something like this: foreach (string kw in keywords) { query = query.Where(p => p.Name.StartsWith(kw)); } The "StartsWit...

LINQ 2 SQL Nested Table Insert Error makes NO SENSE

I have the below LINQ method that I use to create the empty EmploymentPLan. After that I simply UPDATE. For some reason this works perfectly for myself but for my users they are getting the following error --> The target table 'dbo.tblEmploymentPrevocServices' of the DML statement cannot have any enabled triggers if the statement cont...

How to create anonymous objects of type IQueryable using LINQ

Hi, I'm working in an ASP.NET MVC project where I have created a two LinqToSQL classes. I have also created a repository class for the models and I've implemented some methods like LIST, ADD, SAVE in that class which serves the controller with data. Now in one of the repository classes I have pulled some data with LINQ joins like this. ...

database is not updated after submitchanges()

i know this question was asked before but i have this very weird beginner problem: i want to update a list of actors by an id in which film they played (only one film) DataClasses1DataContext db = new DataClasses1DataContext(); var old = from a in db.Actors where a.id == 1 select a; ...

data filter using dataloadoptions

Using dataloadoptions i have tried the following example Northwnd db = new Northwnd(@"northwnd.mdf"); // Preload Orders for Customer. // One directive per relationship to be preloaded. DataLoadOptions ds = new DataLoadOptions(); ds.LoadWith<Customer>(c => c.Orders); ds.AssociateWith<Customer> (c => c.Orders.Where(p => p.ShippedD...

PredicateBuiler (LinqKit) in medium trust

Hey Guys- I am using LINQKit on mosso and am getting an Security Exception about it not being able to run in medium trust. As anyone ran LINQKit in medium trust and been successful? Thanks! ...

What would cause linq to sql to think that a parameter is nullable?

Hi I have a stored procedure that declares a input parameter @BatchNumber uniqueidentifier This field in the table is set to not allow nullables. When I drag in the stored procedure and it hooks everything up it says the parameter is nullable. I don't understand why. Is this normal for it to think that the parameters are nullable?...

How do I do a table join on two fields in my second table?

I have two tables: Messages - Amongst other things, has a to_id and a from_id field. People - Has a corresponding person_id I am trying to figure out how to do the following in a single linq query: Give me all messages that have been sent to and from person x (idself). I had a couple of cracks at this. Not quite right MsgPeople ...

Query data using LINQ to SQL and Entity Framework with foreign key? (Help me please)

Hello! There is a problem I need help with your query on the data using LINQ to SQL and Entity Framework (I'm using Visual Studio 2010). My picure here: http://img.tamtay.vn/files/photo2/2010/5/28/10/962/4bff3a3b_1093f58f_untitled-1.gif I have three tables: tbl NewsDetails tblNewsCategories tblNewsInCategories (See screen 1 in my ...