在Linq中删除到Sql [英] Delete in Linq to Sql

查看:60
本文介绍了在Linq中删除到Sql的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好



i这个linq to sql非常新。



Hi all

i am very much new to this linq to sql.

Dim db As New TestDataContext

        Dim x = From p In db.tblBabloos _
                Where p.name.Contains("tcs") _
                Select p
        db.tblBabloos.DeleteOnSubmit(x)
        db.SubmitChanges()

        Response.Redirect("default.aspx")





这是我用来通过传递代码本身的值来删除记录。



但我想改变它,就像我将在文本框中输入的那个值一样,该值将被删除。

请帮我解决这个问题。



This is i am using to delete a record by passing the value in the code itself.

But i want to change it like which ever value i will enter in textbox, that value will be deleted.
please help me out on this.

推荐答案

如果它在你的代码后面,你应该能够这样做:



If it's in your code behind, you should be able to do it like this:

Dim x = From p In db.tblBabloos _
Where p.name.Contains(txtMyTextbox.Text) _
Select p


这篇关于在Linq中删除到Sql的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆