This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
I've searched and came to these two request threads: http://www.mindscapehq.com/forums/thread/1917 http://www.mindscapehq.com/forums/thread/4847 Why isn't there a LINQ version available of the 'Remove' function? I can understand that a bulk-update procedure could be problematic, but something like: uow.Something.Remove(s => s.SomeProperty < 5); Shouldn't be too hard to implement? Regards, Jerremy |
|
|
There isn't a LINQ version of this because we do have the UnitOfWork.Remove(Query) method available already and there hasnt been any real interest in this outside of the original thread and subsequent request. Ill have a look at whats involved in getting this working as an extension method however and let you know if its something we can look at popping in to the nightlies.
|
|
|
The only reason it's interesting to have a LINQ version is that the Remove(Query) method is not type-safe. Making mistakes easier when the model changes. While unlikely in our current scenario, we like to avoid 'unsafe' methods like Remove(Query), or Execute(SQL), etc. |
|
|
We already had some situations where a linq-delete would have been handy. Currently we use workarounds that first fetch the data from the db and delete the entries afterwards. This is surely not a good and fast solution but currently we can live with that, because the amounts of data are not very high. This might change in the future. Therefore I would really appreciate to have this functionality in LightSpeed. |
|
|
Thanks for the feedback guys. I have added in a new extension method (Remove) which is a basic implementation of this, which really means I havnt spent the additional time looking at adding in restriction checks to filter out any unsupported aspects of the expression you might pass in (e.g. use of subqueries, joins, projections etc). So this will give you equivalent functionality to what can be achieved with UnitOfWork.Remove(Query) currently. This will be available in the next nightly build - your feedback is welcome as always :)
|
|
|
Great, we'll check it out tomorrow or monday. |
|
|
Cool, I have some deletes I'll be happy to change over. Why will queries with joins and sub-selects not work? I know SQL Server supports joins in delete statements but for other databases as long as the query returns the entity type you want to delete then it should be possible to do a
|
|
|
Our update/delete statement builder is somewhat different from the selection one and those aspects of the Query object are not used which is why those things would not work. So while you could express a complex LINQ query with those aspects in it within the context of the Remove call it will end up translating to a Query object which will not be supported by the underlying UnitOfWork.Remove() call. This is the same as if you expressed a Query object which relied on joins or projections or subqueries and then tried to use that with UnitOfWork.Remove().
|
|