Re: LINQ Where 1=0



Hello Chunk

I also did not notice the property ¡°StoreOriginalValuesInViewState¡± at the
beginning of the thread. You may want to have a look at the ¡°Remarks¡±
section of LinqDataSource.StoreOriginalValuesInViewState Property in MSDN:
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.linqdatasource.storeoriginalvaluesinviewstate.aspx

<quote>
By default, when update and delete operations have been enabled, the
LinqDataSource control stores the original values for all the records in
view state. The LinqDataSource control stores values for all primary keys
and all properties not marked with UpdateCheck.Never in the Column
attribute. You set the UpdateCheck property of the Column attribute in the
O/R Designer.

Before LINQ to SQL updates or deletes data, it checks the values in view
state against the current values in the data source. If the values do not
match, the data source record has changed. In that case, LINQ to SQL throws
an exception and does not continue with the update or delete operation. For
more information about LINQ to SQL, see LINQ to SQL.

Storing the original values in view state can cause the page size to become
unnecessarily large and can expose sensitive data to a malicious user. You
can disable storing values in view state by setting the
StoreOriginalValuesInViewState property to false. If you do this, you must
provide your own way to make sure that the data has not changed. If you set
the StoreOriginalValuesInViewState property to false, the original values
are not persisted in view state for the data-bound control. In that case,
LINQ to SQL cannot verify the integrity of the data. LINQ to SQL will throw
an exception that indicates a data conflict even if the data in the data
source has not actually changed.

If the underlying data source contains a timestamp field that is
automatically updated during an update, you can store only that value in
view state. In that case, the timestamp property in the entity class is set
to IsVersion=true and all the properties are set to UpdateCheck.Never.
Because a timestamp field is automatically updated by the database every
time that data in that record changes, LINQ to SQL determines from that
value if data has changed. This helps reduce the size of view state, and no
sensitive data is exposed. LINQ to SQL will check for data consistency by
comparing the timestamp value in view state with the timestamp value in the
database. For more information, see Walkthrough: Using a Timestamp with the
LinqDataSource Control to Check Data Integrity.
</quote>

As well as this walkthrough: Using a Timestamp with the LinqDataSource
Control to Check Data Integrity
http://msdn.microsoft.com/en-us/library/bb470449.aspx

Regards,
Jialiang Ge (jialge@xxxxxxxxxxxxxxxxxxxx, remove 'online.')
Microsoft Online Community Support

=================================================
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msdnmg@xxxxxxxxxxxxxx

This posting is provided "AS IS" with no warranties, and confers no rights.
=================================================

"Chuck P" <Chuck@xxxxxxxxxxxxxxxx> wrote in message
news:D283600C-2438-4D0E-A1EF-17276496D35B@xxxxxxxxxxxxxxxx

I got the delete to work by changing the LinqDataSource to storeviewstate
values.
The documentation says I don't have to:
http://msdn.microsoft.com/en-us/library/bb547113.aspx
The docs aren't to clear though:

If you programmatically create the context object in the Selecting event
and
you do not have to store original values in the view state, the
ContextCreating and ContextCreated events are skipped.

I do create a context object, however, I guess it gets assigned during
e.Result=query?
If I turn viewstate off my sql statement becomes:

DELETE FROM [dbo].[UsersInRoles] WHERE ([UsersInRolesID] = @p0) AND
([RowVersion] = @p1)',N'@p0 int,@p1 timestamp',@p0=75,@p1=NULL

Apparently it doesn't know the value of the TimeStamp, since the value of
NULL is passed. I put the RowVersion in the gridview and got the same
result.


.



Relevant Pages

  • Re: Are Linq-SQL methods commutative
    ... No - in LINQ each step effectively works off the result of the ... linq query which has to meet a SQL query they have in mind. ... freedom a SQL statement gives them: the SQL statement is the one ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: More questions about porting from MySQL to MS SQL
    ... `ab_timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update ... I learned the hard way that MS SQL does not like ... FUNCTION and CREATE VIEW need to be the first statement in a script. ... State what version of SQL Server you are using and specify the content ...
    (comp.databases.ms-sqlserver)
  • Re: Microsofts bridge between OO and relational
    ... Test Drive VB9 and DLinq ... The January 2006 Language Integrated Query (LINQ) preview for the next ... VB.NET, SQL Server 2005, XML, Visual Studio 2005, ... Without reading it all and accepting that a domain is nothing but a data type it has seemed to me a retrograde kind of introspection, even bizarre, to first make relations out of domains, then turn around and make those relations into data types. ...
    (comp.databases.theory)
  • Re: help with tables
    ... SQL0060W The "COBOL" precompiler is in progress. ... While I don't claim the same level of SQL knowledge that you have ... At the moment there is some debate as to whether the addition of LINQ ... I'd drop flat file support ...
    (comp.lang.cobol)
  • Re: approaches for embedding a data language in a general purpose language
    ... have made a wise decision with the linq projecthttp://msdn.microsoft.com/data/ref/linq/where they decided at some ... point to drop their interest in XQuery being handled like SQL. ... unrelated to a dbms the same way you handle data from a dbms. ... for (TObj t in TCollection) ...
    (comp.databases.theory)