开发者

Cast LINQ Function Result to Domain Object

I have a table valued function to perform full text search on 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.

S开发者_Go百科o, 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.

Is there an easy way to cast it back to 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.

:)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜