Multiple parameters in seed lambda expression

I am utilizing the Seed() method to populate my database. I am trying to pre-populate one table with data based on two keys, not just one.

For example, I am doing this elsewhere and it is working fine:

foreach (var drug in Drugs)
{
    context.Drugs.AddOrUpdate(
        d => d.OrderId,
        drug
    );
}

Is it possible to do something like the following?

foreach (var pd in PatientDrugs)
{
    context.PatientDrugs.AddOrUpdate(
        (p => p.DispenseDate && p => p.DrugId),
        pd
    );
}

Answers


Did you try this?

foreach (var pd in PatientDrugs)
{
    context.PatientDrugs
        .AddOrUpdate(p => new { p.DispenseDate, p.DrugId }, pd);
}

Need Your Help

Hibernate assigned generator

java hibernate

The generator element in the hibernate mapping file is supposed to be used to determine how the primary key is generated. Why is the default value assigned bad for detached and transient objects?

Identity Generator in Hibernate with Sybase

java hibernate select generator sybase-ase

I am using hibernate 3.5 with Sybase ASE database.I have a primary key PK1 in my table Table.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.