I have a LINQ to SQL query that returns a grouped collection of Sponsor objects like so:
var result = ( from s in db.Sponsors
join sl in sb.SponsorLevels on s.SponsorLevelId equals sl.SponsorLevelId
select new Sponsor
{
Name = s.Name,
Level = sl.LevelName
...
Why can the Linq to SQL designer not understand the following stored procedure and import it correctly?
CREATE PROCEDURE dbo.MartinTest
@parameter1 INTEGER
AS
SET NOCOUNT ON
SELECT C1, C2, C3
INTO #myTempTable
FROM MyTable
SELECT C1, C2, C3
FROM MyOtherTable INNER JOIN #myTempTable ON ....
RETURN
W...
To get a page from a database I have to execute something like this:
var cs = ( from x in base.EntityDataContext.Corporates
select x ).Skip( 10 ).Take( 10 );
This will skip the first 10 rows and will select the next 10.
How can I know how many rows would result because of the query without pagination? I do not want to run another ...
We've recently started using complied queries in order to improve performance on our Linq to SQL setup. There are several queries that always take multiple seconds to run the first time take under a second in subsequent runs. This appears to be because the compilation doesn't actually take place until the call is made the first time.
I...
I have a Linq to SQL data context class, where I am firing a stored procedure. I can trace through the generated code to where the stored procedure is being fired. I inspect System.Data.Linq.SqlClient.SqlProvider.ExecuteResult and can see that there is a private member called "value" which contains the number of rows updated. There do...
In my project I have about 10 DataContext. My question is whether I have to use global instance or create each single instance of datacontext in a method. Which of the method (from method1 and method2) is better from design point of view.
public class Database
{
USDataContext USDB = new USCDataContext();
//Method 1 Global ...
I have a case in my application where the user can search for a list of terms. The search needs to make three passes in the following order:
One for an exact match of what they entered. Done, easy.
One where all the words (individually) match. Done, also easy.
One where any of the words match...how?
Essentially, how do I, in Linq to ...
Long story short: I am using Linq to sql, but am having issues with its caching
My application is metadata driven, so I do not want caching on (changes in the db should be reflected in the web site on a page refresh). Is there a way to turn caching off? or a way to reset the cache (for example currently when I change data in the databa...
Is it possible to get the column names directly from a datacontext? Below I'm just hard coding the DataTextField and DataValueField, but I'd like to be able to get them from the datacontext if possible. What is the recommended way of getting the column names in a strongly-typed way?
DataClassesDataContext db = new DataClassesDataContext...
I have two database tables, subscription and transaction, where one subscription can have many transactions. The status of the subscription depends mainly on the transactions that belong to it. So if I want to calculate next process date I would look at the period field of the subscription object and then analyze the subscription's tra...
Hello,
I'm using Linq to sql and Linq Dynamic OrderBy.
I know linq dynamic can do simple sorting like - orderby("column_name").
But does it support something more complex like queries with "CASE WHEN" in them ?
string orderbyQuery = "(CASE WHEN (username == 100) THEN 1 ELSE 0 END) DESC)";
here is my query :
var u = from u in db.us...
Having a weird problem. I'm testing an ASP.NET application I wrote that queries SQL server via AJAX. The application is using LINQ-to-SQL to load data from approx 8 or so tables in a join, and every once in a while, the call to SQL server locks up and never returns.
My first thought was that it was getting deadlocked, but from what I'...
I get the above System.NotSupportedException when I want to update an object's with child entities.
The scenario is like this:
I have a SubscriberProvider that allows me to create subscribers.
var provider = new SubscriberProvider(); // Creates a new repository with own datacontext
var newSubscriber = new Subscriber
{
EmailAddress...
Hi, I have a simple LinqToSql query
from p in GL_PROJECTs
where p.CREATE_DT == new DateTime(2009,10,26)
select new p
Some of the records in the database have create dates with time parts other than 00:00:00, so wont be retreived by this query. What I want to achieve is a time insensitive retrieval for the whole day.
I tried the fol...
I'm switching code generators for my business objects. I was using SQL Metal, but in moving to the T4 toolbox's generator, serialization seems to have stopped working, and it looks like the two are doing pretty much the same thing.
This is the property generated by SQL Metal (which works):
[Association(Name="FK_FamilyConfiguration_Fam...
Suppose you have a single web portal application that is used by a number of different clients. For reasons of security and portability, each client's data must reside in a separate database. The schema for each of these databases is absolutely identical.
How does one go about accessing these separate databases from a single SQL Serve...
hey all. Just wanting to know is this the most efficient way of getting values from a db: given;
----------- --------------- -------------
| Channel | |Issue | |Topic |
| path(ck)| |channelID(fk)| |issueID(fk)|
----------- --------------- -------------
One channel has many Issues
One Issue has man...
I just upgraded a project to 3.5 SP1
and trying to add a LINQ to SQL class item to the project and can't as it doesn't appear in the Add Item list.
Though if i create a new project in the same solution and try adding it the item (LINQ to SQL classes) is available and I can add it to the project.
What do i have to do to be able to add L...
Is there anyway I can change the namespace of the classes generated by LINQ to SQL
right now it goes ProjectName.FolderName
Is there anyways I can change this default convention
...
What is the life cycle of a data context.
MyDB_DataContext db = new MyDB_DataContext();
Is it more efficient to pass one context across several methods or create new instances of it. OR is there any reason to choose one over the other
public void DoStuff(){
MyDB_DataContext db = new MyDB_DataContext();
doMoreStuff()
}
private ...