S
S
Sergey Melnikov2015-12-29 20:57:21
ASP.NET
Sergey Melnikov, 2015-12-29 20:57:21

How to determine record id in asp.net by text field db.Mods.Find(id) doesn't work?

It is necessary to find the record id by some method to EF, by another text field, how to do this?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anatoliy Mikhailov, 2015-12-30
@yamaoto

If I understand correctly, you want to get a specific entry or its IDs?
If the field is not unique, then you need to take into account that there can be several such records
If the field is unique
Or if this field is a foreign key, then you can

var itemId = db.Mods.Single(m=>m.SomeField==model.SomeField).Select(m=>m.Id);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question