[英]Cast LINQ Function Result to Domain Object
I have a table valued function to perform full text search on SQL server. 我有一个表值函数,可以在SQL Server上执行全文搜索。
The result type of my full text search function in LINQ is a special autogenerated type which includes KEY and RANK in addition to my regular domain object properties. 我在LINQ中的全文搜索功能的结果类型是一种特殊的自动生成的类型,除了我的常规域对象属性外,还包括KEY和RANK。
So, if my regular domain object is PERSONS (with properties FirstName, LastName etc.), I also have a result object PERSONS_FTSResult with the same properties + KEY and RANK. 因此,如果我的常规域对象是PERSONS(具有属性FirstName,LastName等),则我还将有一个具有相同属性+ KEY和RANK的结果对象PERSONS_FTSResult。
Is there an easy way to cast it back to PERSONS? 有一种简单的方法可以将其投射回PERSONS吗?
Couldn't you do something like this: 你不能做这样的事情:
var x = from data in searchResults
select new {
key = data.Key,
rank = data.Rank,
person = new Person { firstName = data.FirstName }
};
Person p = x.First().person;
I apologize if a bit of the syntax is bad, but I'm playing Eve Online, not coding right now. 如果某些语法不好,我深表歉意,但是我正在玩Eve Online,现在没有编码。
:) :)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.