基类:
public abstract class SolrSearcher<Record, Result> : Searcher<Result>
{
protected SolrSearcher();
protected abstract string SolrCoreName { get; }
protected virtual QueryOptions BuildQueryOptions(SearchCondition condition);
protected abstract Result TransformSolrQueryResult(SolrQueryResults<Record> solrQueryResult, SearchCondition condition);
}
实现类方法:
new protected QueryOptions BuildQueryOptions(SearchCondition condition)
{
//此方法硬要说返回值和基类不同,不得已才用了new
}
protected override WeaponrySearchResult TransformSolrQueryResult(SolrQueryResults<Weaponry> solrQueryResult, SearchCondition condition)
{
//省略掉了
}
错误 3 “DefenderKingdom.Service.WeaponrySearcher.BuildQueryOptions(DK.Utility.DataAccess.SearchEngine.SearchCondition)”: 返回类型必须是“SolrNet.Commands.Parameters.QueryOptions”才能与重写成员“DK.Utility.DataAccess.SearchEngine.Solr.SolrSearcher<DefenderKingdom.Entity.Weaponry,DefenderKingdom.Entity.WeaponrySearchResult>.BuildQueryOptions(DK.Utility.DataAccess.SearchEngine.SearchCondition)”匹配 C:\Users\duguk\Desktop\DefenderKingdom\DefenderKingdom.Service\WeaponrySearcher.cs 20 41 DefenderKingdom.Service
错误 4 “DefenderKingdom.Service.WeaponrySearcher.TransformSolrQueryResult(SolrNet.SolrQueryResults<DefenderKingdom.Entity.Weaponry>, DK.Utility.DataAccess.SearchEngine.SearchCondition)”: 没有找到适合的方法来重写 C:\Users\duguk\Desktop\DefenderKingdom\DefenderKingdom.Service\WeaponrySearcher.cs 34 49 DefenderKingdom.Service
我简直醉了
错误 2 “DefenderKingdom.Service.WeaponrySearcher”不实现继承的抽象成员“DK.Utility.DataAccess.SearchEngine.Solr.SolrSearcher.TransformSolrQueryResult(SolrNet.SolrQueryResults`1, DK.Utility.DataAccess.SearchEngine.SearchCondition)”
我已经知道问题出在什么地方,出在SolrNet.SolrQueryResults`1这个‘1上,请问这种情况怎么处理呢
亲,编译时都给出提示了,返回类型与基类不符啊。
protected QueryOptions BuildQueryOptions(SearchCondition condition)
改成
protected SolrNet.Commands.Parameters.QueryOptions BuildQueryOptions(SearchCondition condition)
写成这样也不行的
抽象方法和虚拟方法都用override重写
终于解决了,其实是dll版本的问题