c# - MS SQL how to record negative time -


i have column in ms sql database type “time”. need record negative value in it. isn't range between 2 times or dates. it’s abstract value of time used in calculations. in entity framework treated timespan, metadata.tt automatically time defined columns in database.

for example, might have arbitrary calendar events @ 5am , 8pm on monday, 1 @ 4pm on tuesday, , 1 @ 3am on sunday after that. add value these times , time either before (in case of negative time), or after (in case of positive time) beginning of event.

when try write down negative value, database refuses it.

the recording of entity database goes direct bind of post attributes in controller, if needs translated ticks, reliable in javascript? how go input textbox it? looks cannot separate value content in text box. , if have turn int, cannot use @editorfor on anymore, creating point of fault code becomes less flexible.

it feels should create new columns denote negativity of these values , use dropdown list hidden inputs instead of textbox.

edit: why avoid non-time types:

consider code:

var typename = _code.escape(edmtype.metadataproperties.where(…).firstordefault()); 

if edm property has type int, generated code type int. edm property comes database itself, if not type translates directly time, there need new method (somewhere in helper, perhaps), translates time. new method have maintained (by other people on team), means weak point, because if changes column name, code not generated again.

errors may not available through error log, since properties tend referenced in javascript @ point (which generated, , can't column because special case). i'm talking 20 columns suffering this, has potential turn tangled ball of spaghetti.

it seems trying store duration, not time. time used storing point in time, not amount of time. choose subdivision of time (second, millisecond, etc), , store int (or bigint if necessary). in sql server use dateadd(second,@storedvalue,@datetochange) calculate true time or datetime.add.milliseconds(storedvalue) or datetime.add.seconds(storedvalue), on, in c# when trying calculate time want.

let me know if i'm missing something.


Comments

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -