使用ExecuteStoreQuery方法 [英] Using ExecuteStoreQuery method

查看:69
本文介绍了使用ExecuteStoreQuery方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我有两个不同模型的两个表(即edmx文件)我想使用join来获取一些数据,以便我的RnD现在停止是不是这样做两个模型之间的连接,我也不想使用存储过程,所以我决定使用
ExecuteStoreQuery。

I have two tables in two different model (i.e. edmx files) i want to use join to get some data so as per my RnD uptill now there is no such way to do the join between two model, I dont want to use the stored procedure as well so i have decided to use ExecuteStoreQuery.

我做了一个查询而不是用这个方法执行它并传递我的POCO类(即用CSDL和SSDL中的模型进行类寄存器)。我还在此POCO中包含一些其他属性,这些属性不为实体框架所知,因此我的查询将
工作并映射该数据,但遗憾的是我没有映射未在edm中注册的其他属性。

然后我再次执行一些查询,创建一个与EDM无关的新类,与POCO(第一类)的任何方式和属性相同,并且工作正常。

任何人都可以知道它有什么问题。 ExecuteStoreQuery在POCO中映射结果有一些限制。我的属性都是原始的并不复杂。 

您的任何答案都会有所帮助。谢谢

Your any answer will help. Thanks

推荐答案

如果您在POCO类中提供的属性名称和从ExecuteStoreQuery返回的列相同,它应该映射。

By right, it should map if the property name that you gave in POCO class and the column return from ExecuteStoreQuery are same.

//Sample ExecuteStoreQuery

var thislist = context.ExecuteStoreQuery<Catego>("Select *, (CategoryId*2) as total from Categories");





//Custom class on Northwind Categories + additional property, total
public class Catego
{
    public int CategoryID { get; set; }
    public string CategoryName { get; set; }
    public string Description { get; set; }
    public byte[] Picture { get; set; }
    public int total { get; set; }
}




希望这会有所帮助。


Hope this helps.


这篇关于使用ExecuteStoreQuery方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆