I have multiple result set that return data form customer table(singlr record) and customer adresses(multiple records). when I retrive the data for first time it bring the correct data but when I update it and save the changes(Iam sure that the data are updated in database) it bring the old version for customer and the new data for custo...
Hi
I have a table that looks like the following:
TABLE Foo
{
Guid Id [PK],
int A [FK],
int B [FK],
int C [FK],
}
And unique constraint over A, B and C.
Now say for example, you insert a row with a fresh PK with with A = 1, B = 1, C = 1.
SubmitChanges(), all happy.
Now you edit the table.
You remove the previous entry, and...
I am in the process building myself a simple Linq to SQL repository pattern.
What I wanted to know is, is it possible to set a default sort column so I don't have to call orderby.
From what I have read I don't think it is and if this is the case what would recommend for a solution to this problem.
Would the best idea be to use an att...
Say I have a few tables in the MSSQL database, each with about 5-10 attributes. There are some simple associations between the tables, but each of the table have 500,000 to 1,000,000 rows.
There is an algorithm that runs on that data (all of it), so before running the algorithm, I have to retrieve all the data from the database. The alg...
How can I get the number of records that were inserted?
Is there an easier way, with L2S, than count before and count after and taking the difference?
...
Is it possible to write a select statement that also has NOLOCK and TOP in LINQ?
What about setting RowCount before the query?
...
Hi everyone,
I guess I'm old school, when I architect a project I still think of writing a database layer that includes use of objects like datareaders and datasets... But it seems to me that Microsoft had to come up with better tools since my last project in 2.0, something that would hide all the pipping labor and keep the developer fo...
i am trying to insert a data class in dbml file which each property contains another data class. Its quite similar to tree structure.
for example a class A contains two property which are role and user. role and user are other classes.
if any other query is required then mail me [email protected]
...
I've got a stored procedure that returns two possible result sets. If successful, it returns a 0 (int). If it fails it returns -1 and a table containing a list of errors. I'm trying to figure out how to deal with this using LINQ.
I found Scott Guthrie's post about this, but he was using results that were mapped to types/tables. I had t...
In creating a new ASP.NET MVC application, I have an issue with the approach I'm using to store user-created data for temporary users who have yet to create an account which I then try to convert to a real user. That probably doesn't make much sense, so let me explain:
A visitor to the site can enter profile settings before being made ...
I have to import the content of 4 tables from an old database into SQL 2005 for easier reporting.
Products contains the id and product name, ProductProperties contains a variable number of properties for each product, Ingredients contains a variable number of ingredients for each product, and IngredientProperties contains the same prope...
I need to retrieve random rows from SQL Server database. I am looking for a way to achieve this using LINQ query. Is it possible?
SQL Query: SELECT [Id] FROM [MyTable] ORDER BY NEWID()
What is the equivalent LINQ query for the above SQL?
Thanks in advance.
...
Hi Geeks,
I've a stroe procedure to update a record and after running it I use LinqToSql to delete the record. I know it is weird but I just want to test how smart the datacontext it is and understand how it works.
Since the datacontext caches the results so any change via it can be recorded but now I use a store procedure to update so...
I have a Linq-to-SQL class, and I'd like to perform some pre-save validation before the record is persisted to the DB. In addition, once it has been saved, I'd like to have some post-save processing code.
Similarly, when a record is deleted, I'd like to have pre- and post- methods that will be called, no matter from where the context.S...
I do understand SQL querying and syntax because of previous work using ASP.NET web forms and stored procedures, but I would not call myself an "expert" in it.
Since I have been using ASP.NET MVC and LinqToSql it seems that so much of the heavy lifting is done for me and encapsulated away at the SQL end that I'm questioning whether ther...
Is there a way to use UPDLOCK with LinQ To SQL? I have a scenario that needs it.
Thanks!
...
I have a need to replace multiple strings with others in a query
from p in dx.Table
where p.Field.Replace("A", "a").Replace("B", "b").ToLower() = SomeVar
select p
Which provides a nice single SQL statement with the relevant REPLACE() sql commands.
All good :)
I need to do this in a few queries around the application... So i'm lookin...
I am using LINQ to SQL to insert simple data into a table WITHOUT a stored procedure. The table has a Primary Key ID column, which is set as an IDENTIITY column in both SQL Server and in my DBML.
First I call InsertOnSubmit(); with data for a single row, and then I call SubmitChanges(); to commit the row to the db. But I think there m...
I have a statement similar to this that I need to run in Linq. I started down the road of using .Contains, and can get the first tier to work, but cannot seem to grasp what I need to do to get additional tiers.
Here's the SQL statement:
select *
from aTable
where aTableId in
(select aTableId from bTable
where bTableId in
...
How to translate the following query to Linq?
SELECT DISTINCT TOP 10 A.*,A.X+A.Y AS SUMXY
FROM TABLE_A AS A INNER JOIN TABLE_B AS B ON A.ID = B.AID
ORDER BY SUMXY
I don't want to split in two queries.
...