【发布时间】:2018-01-29 13:04:36
【问题描述】:
我有一个像这样的存储过程“GET_PARTNER”:
SELECT
...
Partners.name AS 'name' -nvarchar
Partners.city AS 'city' -nvarchar
NULL AS 'sales' -money
NULL AS 'comments' -nvarchar
...
我已将实体框架 6 添加到项目中,并将其设置为从数据库创建模型,它会创建一个模型“GET_PARTNER_Result”,如下所示:
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated from a template.
//
// Manual changes to this file may cause unexpected behavior in your application.
// Manual changes to this file will be overwritten if the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace WSExport.Model
{
using System;
public partial class GET_PARTNER_Result
{
public string name {get; set;}
public string city {get; set;}
public Nullable<int> sales {get; set;} -wrong datatype
public Nullable<int> comments {get; set;} -wrong datatype
}
}
如何修改存储过程,或者是否可以配置 ef 以便创建具有正确数据类型的模型? 像这样:
public Nullable<decimal> sales {get; set;}
public string comments {get; set;}
【问题讨论】:
标签: c# sql-server entity-framework tsql stored-procedures