C# - Does LINQ To SQL Auto Update The LOCAL/CLIENT Id Column After A SubmitChanges Call
Jan 18, 2010
want to know if linq to sql auto updated the id column of a class (table row object) after SubmitChanges is called inserting a new row to that table, that would be fantastic, would anyone be able to confirm this?
I am working on a content management system which is being sort of retrofitted onto an existing database, and the database has many many tables. There will be a staging database, where we will make changes and allow users to 'preview in place'. Then any changes have to be approved, and to publish them we will connect to a live version of the same database (same schema) and play-forward the captured changes.I have found some code (called Doddle Audit) which, with some customization, is giving me great information about what is changing. I am able to get a list of all columns, before and after, for updates, inserts, and deletes. But what I would really like to have is the underlying SQL being run by SubmitChanges(). LinqToSql has to generate this, so why can't I have it? I have googled around and looked at code involving SubmitChanges, mousing over stuff, and I can't seem to find it. Does anyone know of a way to obtain this?
In my 2nd ASP.NET MVC project I'm facing a very weird problem: when I call the SubmitChanges method of the DataContext class, nothing updates in the database. It's weird because everything works fine with my first project. I'm using a remote database created in Sql Server Management Studio, I tried doing some queries there and in Visual Studio 2010 (where I have the connection to the database), they all work. Where might the problem be hidden?
DBDataContext DB = new DBDataContext(); var myuser = DB.Users.Single(u => u.ID == id); myuser.Age = 45; DB.SubmitChanges();
This is embarrassing :D Indeed I didn't have a primary key. Now it works!
I was trying to delete records from database and sometimes on production, the SubmitChanges() goes through and updates the associated entities yet the data does not gets deleted in the database.This is happening only in production and I could not replicate the same on stage or on my local machine. Now the table in which I am performing the delete transaction does have primary keys.
Is there a way I can automatically update a 'Date' column in my database table to the current date whenever any cell in that record is updated?I've started looking into table triggers a little bit and I'm wondering whether I can do it using this?
I have a page setup that displays a datagrid connected to a access database file. I setup a timer to compare the last write time of the access db file and current time (with in 4 seconds). Once the times are with in 4 seconds of each other it requests a refresh of the data. The webpage is displayed on 4 thin client PC's with 0 user involvement so the WebPages need to update themselves. Due to the fact I'm limited to Access I'm trying to limit the # of times a day they are accessed by the auto-update.
The problem I'm having is when the timer ticks it POSTs to the web server. I have 3 WebPages setup watching 3 DB's for different location where I work but they all run of an IIS server in my office. So this creates a lot of unneeded traffic and log files. (Currently 5-6megs per day)
I was wondering there is a better way to compare the files on the clients machine and only post back for an update when they are with in 4 seconds of each other.
The site is built with MS visual web dev 2010 express written in Aspx and code lang is VB. I'm using system.io.file.getlastwritetime to get the file information for comparing.
do you think it would be difficult to write a framework where mvc compares last html it output to the current html we want to output, and instead of sending the entire html, figure out what has changed and generate js code that will do the updating as compared to previous html? (presuming nothing was manually changed on the client using js).
I have a gridview which has a column of auto generated select buttons, where a user can select a row.However, I would like to add a column header to my auto generated select buttons in order to make the gridview look complete, but I am unable to see how I can do this. Does anyone know how I can add a header text to an auto generated select button?
when I insert any character to column Name then A new string random will auto insert into column Random (picture below) I had used Trigger but It was error !
I want to column Random use to code :
DECLARE @myid uniqueidentifier SET @myid = NEWID() insert into table_1 values(@myid, substring(CONVERT(varchar(255), @myid), 1, 5))
but It must auto like column Number (column Number is Identity)
I just want to do a select in one SQL SERVER TABLE using LINQ to SQL. And this select statment needs to compare one SQL filed to one hashtable key value.
Dim q = From product In db.productDB _ HashVar As DictionaryEntry In MyHashTableVar, _ Where _ product.productID = HashVar.Key
"Local sequence cannot be used in LINQ to SQL implementation of query operators except the Contains operator"
I used the auto generated models to use my existing SQL server in a new website.in some forms I use rich text editor (CKEditor) so I added [ValidateInput(false)] to those post back actions. but that is a bad solution 'caus I have lost of other from items which needs validation. I came across a potential solution to that using [AllowHtml] which I need to add to the model properties. I tried that:
[Code]....
but that is an error "type or namespace couldn't be found.."any ideas about where the [AllowHtml] attribute should be?
In a database table, let's say I have a non-null field named "Description" with a default value of (''). If I drag this table onto the .dbml view in Visual Studio and click on the Description field, the properties will indicate that the Auto Generated Value is set to false, thus ignoring my default value of (''). This is fine, as long as I always explicitly set a value for Description when I perform an insert/update, but I ran into a problem today when I tried to do an insert without specifying a value for Description: Cannot insert NULL value into Description. The default value I set for the field was being ignored. To try and fix this error, I went back into the .dbml and set Auto Generated Value to true, and tried again - no error this time, but the data I tried to insert was ignored, and the default value, (''), was inserted instead. I do not want to explicitly set every field to a default value programmatically when I perform inserts. Is there any other way to resolve this issue other than making the fields nullable?
I have been tasked with a duty to get auto complete to work on a simple employee search web form that I have created. And after looking at the tutorial I have an idea of how to get auto complete working and in the instance of my page I have it working with the sample data from the tutorial. So my question is this. How do I get it to work/quary from the SQL database that I have? I have tried several combinations and I can't seem to get it to pull from the DB. Below is the full code to my C# page with LINQ
I use Visual Studio 2010 and MS SQL Express edition. .NET 4.0
Database model is very simple. I have articles and each articles has a category. Simple relationship 1 category many articles.
So to take all articles I use code:
[Code]....
and it's automatically loads Category reference and all Category references to. So it's looks like it's load all nested fields automatically. How I can deny this?
I was thinking that I should use .Include("Category"), but it seems that it's don't needed.Problem is that when I try to send it it's throw an exception:
The maximum read depth (32) has been exceeded because XML data being read has more levels of nesting than is allowed by the quota.
it should be in asp.net. but, it is urgent and important, wish someone here know the answer.
what I need do for an asp.net page is:
1) client select a file, or; 2) client select a folder;
Get file (or files in the folder)'s properties, something like name, ext, etc. and save to db.
it will be easy if it is a desktop app. however, in asp.net, how can I do that? do I have to upload all files to server first? is there a way to do this for all files in a folder? any third party control?
2) client select a folder; Get file (or files in the folder)'s properties, something like name, ext, etc. and save to db.
it will be easy if it is a desktop app. however, in asp.net, how can I do that? do I have to upload all files to server first? is there a way to do this for all files in a folder? any third party control?
I want local/Client machine ip address, for that i have written below code. but this code gives me Application server address where my web site is hosted. where as i wanted client machine IP from where my web site is getting accessed. so if my website accessed from 10 different machine in that case i want 10 different IP address of those machines.
What could potentially stop an AJAX call from working on the host server, when it works fine on the local host? I tried returning an error from the AJAX call, but all I get is 'undefined'. I don't think the actual page method is being called since no information is added in my log (and I've explicitly added a call).
is this c# code intended to read local client files?System.IO.FileStream content = System.IO.File.Open("c: est.txt", System.IO.FileMode.Open);It gives me error FILE NOT FOUND
I've exempted the irrelevant bits of code. Essentially, I am trying to change the URL of an image control inside of an update panel inside of a custom user control from a function called inside an update panel from my main page. Using UpdatePanel.Update() isn't working: I end up waiting for the next full page POST to occur before all the updates I make to CustomControl from buttons within the main page's update panel are visible. I verified that Update() was being called via the debugger: there are no issues in that department.
Here, you can see Custom Control and the Button declared. The button is in an update panel to avoid giving a full POST and causing the whole page to reload.
This control stores images within their own seperate update panels because rerendering the images is very slow (it requires processing arrays of millions of datapoints) and the user only ever needs to modify one image at a time. I'm using Image1 as an example.
how to catch update panel's request start (before partial updation request is sent to server) and response receive (before update panel is updated) events.