SubSonic 3 忽略 Select() 中的列
我有一个像这样的表..
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我一直无法解决这个问题。我最终只是执行了一个普通的旧 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.