SubSonic 3 忽略 Select() 中的列

发布于 2024-08-28 16:08:37 字数 1644 浏览 6 评论 0原文

我有一个像这样的表..

CREATE TABLE [dbo].[Locations_Hours](
  [LocationID] [int] NOT NULL,
  [sun_open] [nvarchar](10) NULL,
  [sun_close] [nvarchar](10) NULL,
  [mon_open] [nvarchar](10) NULL,
  [mon_close] [nvarchar](10) NULL,
  [tue_open] [nvarchar](10) NULL,
  [tue_close] [nvarchar](10) NULL,
  [wed_open] [nvarchar](10) NULL,
  [wed_close] [nvarchar](10) NULL,
  [thu_open] [nvarchar](10) NULL,
  [thu_close] [nvarchar](10) NULL,
  [fri_open] [nvarchar](10) NULL,
  [fri_close] [nvarchar](10) NULL,
  [sat_open] [nvarchar](10) NULL,
  [sat_close] [nvarchar](10) NULL,
  [StoreNumber] [int] NULL,
  [LocationHourID] [int] IDENTITY(1,1) NOT NULL,
 CONSTRAINT [PK_Locations_Hours] PRIMARY KEY CLUSTERED 
(
  [LocationHourID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

SubSonic 3 正在生成一个具有以下属性的类

int LocationID
string monopen
string monclose
string tueopen 
string tueclose
string wedopen 
string wedclose
string thuopen 
string thuclose
string friopen 
string friclose
string satopen 
string satclose
string sunopen 
string sunclose
int? StoreNumber
int LocationHourID

当我尝试像这样对此类执行查询时,

var result = DB.LocationHours.Where(o => o.LocationID == _locationId);

..这是 SubSonic 生成的 SQL 查询结果。

SELECT [t0].[LocationHourID], [t0].[LocationID], [t0].[StoreNumber]
FROM [dbo].[Locations_Hours] AS t0
WHERE ([t0].[LocationID] = 4019)

我无法弄清楚为什么 SubSonic 在生成 SELECT 语句时省略 nvarchar 字段。有人有什么想法吗?

I have a table like so..

CREATE TABLE [dbo].[Locations_Hours](
  [LocationID] [int] NOT NULL,
  [sun_open] [nvarchar](10) NULL,
  [sun_close] [nvarchar](10) NULL,
  [mon_open] [nvarchar](10) NULL,
  [mon_close] [nvarchar](10) NULL,
  [tue_open] [nvarchar](10) NULL,
  [tue_close] [nvarchar](10) NULL,
  [wed_open] [nvarchar](10) NULL,
  [wed_close] [nvarchar](10) NULL,
  [thu_open] [nvarchar](10) NULL,
  [thu_close] [nvarchar](10) NULL,
  [fri_open] [nvarchar](10) NULL,
  [fri_close] [nvarchar](10) NULL,
  [sat_open] [nvarchar](10) NULL,
  [sat_close] [nvarchar](10) NULL,
  [StoreNumber] [int] NULL,
  [LocationHourID] [int] IDENTITY(1,1) NOT NULL,
 CONSTRAINT [PK_Locations_Hours] PRIMARY KEY CLUSTERED 
(
  [LocationHourID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

And SubSonic 3 is generating a class with the following properties

int LocationID
string monopen
string monclose
string tueopen 
string tueclose
string wedopen 
string wedclose
string thuopen 
string thuclose
string friopen 
string friclose
string satopen 
string satclose
string sunopen 
string sunclose
int? StoreNumber
int LocationHourID

When I try to perform a query against this class like so..

var result = DB.LocationHours.Where(o => o.LocationID == _locationId);

This is the resulting SQL query that SubSonic generates.

SELECT [t0].[LocationHourID], [t0].[LocationID], [t0].[StoreNumber]
FROM [dbo].[Locations_Hours] AS t0
WHERE ([t0].[LocationID] = 4019)

I cannot figure out why SubSonic is omitting the nvarchar fields when it generates the SELECT statement. Anyone got any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

拥抱没勇气 2024-09-04 16:08:37

我一直无法解决这个问题。我最终只是执行了一个普通的旧 DataReader 并“手动”填充我的对象。

如果有人稍后提出答案,我将更改已接受的答案。

I wasn't ever able to solve this problem. I ended up just executing a plain old DataReader and 'manually' populated my objects.

If anyone comes along later with an answer, I will change the accepted answer.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文