English 中文(简体)
SQL SQL 服务器校验和( EF)
原标题:SQL Server checksum in EF

我在 SQL 服务器有一张像这样的桌子 :

<强度 > 用户 :

int ID PK Identity
nvarchar(50) Username
nvarchar(50) Password

我将校验和字符串存储在 Password 栏中, 并使用此方法进行散列密码并将其存储在表格中

现在我想用这个EF的表格 像这样 ;

User = DBContext.Users.SingleOrDefault(rec => rec.Username == Request["U"] && rec.Password == Request["P"]);

但由于我将校验和值存储在表格中,所以我必须更改 request[“P]> 来将其用于 EF

抱歉我是新来的英语, 你有没有发现我说的是什么? (我希望我能清楚地解释我的问题: ()

<% 1>/% 1 : 如果我有这样的查询 :

Select * from Users where username = @p1 and password = checksum(@p2)

我如何转换@p2 来使用这样的查询 :

Select * from Users where username = @p1 and password = @p2 --Checksum omitted
最佳回答

只要您正在使用数据库第一( 这意味着您有 EDMX ), 您就可以添加 < a href=" http:// msdn. microsoft. com/ en- us/library/ dd456812. aspx" rel = "nofollow" > 习惯函数 像这样 :

SELECT CHECKSUM(@password)

对 EDMX 来说,然后您可以拨打它来计算密码的校验和值,然后在 LINQ 查询中使用密码。

问题回答

暂无回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签