Answer the question
In order to leave comments, you need to log in
Querying data from a database with multiple conditions
Good afternoon, dear% username%.
There is a C# class with the following content:
namespace Dzen_volunteer
{
public class Volunteer : DataContext
{
public Table<Person> Persons;
public Volunteer(string connection) : base(connection) { }
}
[Table(Name = "Persons")]
public class Person
{
string _guid;
[Column(IsPrimaryKey = true, Storage = "_guid")]
public string Guid
{
get
{
return this._guid;
}
set
{
this._guid = value;
}
...куча полей...
}
}
}
foreach (Person pers in db.Persons)
{
this.listPersons.Add(pers);
this.personList.Items.Add(pers.FirstName + " " + pers.FatherName + " " + pers.LastName);
}
where pers.Field==""
where pers equals person
Answer the question
In order to leave comments, you need to log in
If anyone else is interested, then everything is solved quite simply, as it turned out.
You should use a where construct similar to the following:
where pers.FirstName == (AddForm.Person.FirstName == "" ? pers.FirstName : AddForm.Person.FirstName) && pers.LastName==(AddForm.Person.LastName=="" ? pers.LastName:AddForm.Person.LastName) ... остальные условия...
As far as I understand, you need to make a selection on an array of values of some field, then you need to use Contains , which will create a WHERE IN construct in SQL. See this link for an example: Linq-To-Sql: Alternative to the 'WHERE IN' Expression
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question