Sunday 15 March 2015

SQL & C# Search for a record and expect a record or a set of records? -



SQL & C# Search for a record and expect a record or a set of records? -

this might seem subjective, i'm looking answers set, or @ to the lowest degree part of setting, coding standards.

in c#, type of result should expect when searching single record non primary key index?

if :

select * tablename fieldname=@fieldname

as matter of practice, should code logic expect ienumerable list or single record?

if expect 1 record, should sql utilize top 1? below:

select top 1 * tablename fieldname=@fieldname

i think rather thinking expect, improve way @ build query such want. if interested in 0 or 1 potential matches top(1) works. although i'd add together type of ordering clause.

however, if want 0 or more, first approach better.

any time querying based off of non-unique value have possibility of returning more 1 record. sure, today query gets one. @ point in future unforseen alter occur , of sudden multiple rows back.

c# sql

No comments:

Post a Comment