简体   繁体   English

使用Solrnet并使用实体框架生成的POCO分配属性

[英]Using Solrnet and Assigning Attributes with Entity Framework Generated POCOs

I will be using Solr search server with my ASP.NET 4.5 application. 我将在我的ASP.NET 4.5应用程序中使用Solr搜索服务器。 I've already installed SOLR on my Windows 8 laptop computer. 我已经在Windows 8便携式计算机上安装了SOLR。 According to SolrNet this documentation , I need to use specific attributes on my POCOs. 根据SolrNet 此文档 ,我需要在POCO上使用特定的属性。

The thing is that I am using Entity Framework and my classes are auto generated. 问题是我使用的是Entity Framework,并且我的类是自动生成的。 Is there an option to assign those type of Solr attributed and also make sure that they are presistant and won't be erased if your suggested solution is based on editing the template (.tt) file. 是否有选项可以分配归因于这些类型的Solr,并且如果建议的解决方案是基于编辑模板(.tt)的,则还可以确保它们是可抵抗的且不会被擦除。

I want to use Entity Framework, but if it is not possible, I will just copy the pocos and create the classes myself with those Attributes. 我想使用实体框架,但是如果不可能,我将复制pocos并使用这些属性自己创建类。 But I prefer searching for a solution that will allow me to use solrnet with Entity Framework. 但是我更喜欢寻找一种解决方案,该解决方案使solrnet与Entity Framework结合使用。 Thanks. 谢谢。

I would suggest that you create separate classes that map to your Solr Index schema, as typically the structure of your EF classes and your index schema will not be identical. 我建议您创建映射到Solr Index模式的单独的类,因为通常EF类的结构和索引模式将不相同。 This way you have a clean separation between your persistence classes (those auto-generated by EF) and your index mapping classes and can control how the mapping between the two occurs. 这样,您就可以在持久性类(由EF自动生成的持久性类)和索引映射类之间进行清晰的隔离,并可以控制两者之间的映射发生方式。 I recommend the use of AutoMapper to assist with translating your objects from EF to Solr and back again as needed. 我建议使用AutoMapper来帮助将对象从EF转换为Solr,然后根据需要再次转换。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM