如何将数据类型属性设置为smalldatetime

时间:2010-05-13 14:43:09

标签: c# ado.net c#-4.0 entity-framework-4 code-first

有办法吗?以下不起作用:

var customer = constructor.Entity<Customer>();
customer.Property(c => c.Date).DataType("smalldatetime");

2 个答案:

答案 0 :(得分:5)

customer.Property(c => c.Date).HasStoreType("smalldatetime");

答案 1 :(得分:0)

我的代码第一种方法:

    declare  @valcheck table
(
    id int identity(1,1) primary key,
    payload varchar(100)
)

insert into @valcheck(payload) 
values('{"Transaction":"123456","Transaction2":"789123"}'),
      ('{"Transaction":"123457","Transaction2":"789124"}')


select id, [1] as 'Transaction1',[2] as 'Transaction2' from @valcheck a
cross apply(
            select [1],[2] from
                (select dbo.RegExMatch('(?<=:")\d+',Match,1) as match, 
                        row_number()over(order by (select 0)) as rn 
                        from dbo.RegExSplit(',',a.payload,1)) as D
        pivot
           (max(match) for rn in ([1],[2]) ) as pivoteed
)c