Luceneインデックスの結果を得るには、次のコードを使用しています。私は上記のクエリでDbFunctions
を使用しない場合、私は正確に一つのレコードを取得IQueryableでDbFunctionsを使用してLuceneインデックスを検索する方法
Exception Details: System.MissingMethodException: No parameterless constructor defined for this object.
:
using (var context = ContentSearchManager.GetIndex("my_profile_index").CreateSearchContext())
{
IQueryable<ProfileSearchItem> query = from profile in context.GetQueryable<ProfileSearchItem>()
where profile.LastName.Equals("Zafar")
let diffYears = DbFunctions.DiffYears(profile.Birthdate, DateTime.Today)
select profile;
return query.ToList();
}
私は理由DbFunctions.DiffYears
の例外を取得します。私はインデックスを検索中にDbFunctions
を使用する方法を知りたいです。これは単なるサンプルクエリです、私の唯一の目的はタイトルに記載されています。
ProfileSearchItem
クラス:
public class ProfileSearchItem
{
[IndexField("_group")]
public string ItemId { get; set; }
[IndexField("_language")]
public string Language { get; set; }
[IndexField("birthdate")]
public DateTime Birthdate { get; set; }
[IndexField("first_name")]
public string FirstName { get; set; }
[IndexField("last_name")]
public string LastName { get; set; }
}