+ 1

DbRawSqlQuery return dataType?

Hi there, I have a simple question and yet it still quite a bit off of me. So, var A = _context.Database.SqlQuery<TableName>("usp_MyStoredProcedure").ToArray(); Will it really return as Array? As of ["a", "b"]? I usually go with ToList(). But, this case i need to send notif via FCM (to multiple devices) which it must use Array. Thanks all

6th Nov 2020, 3:58 PM
Radendy Bahtiar
Radendy Bahtiar - avatar
1 Answer
+ 4
Yes, will return data as array. I think you must review array vs list topic https://www.sololearn.com/discuss/1206722/?ref=app https://www.sololearn.com/discuss/1662872/?ref=app https://www.sololearn.com/discuss/1646714/?ref=app https://www.sololearn.com/discuss/2018653/?ref=app https://www.sololearn.com/discuss/2191687/?ref=app In general, it’s better to use lists in C# because lists are far more easily sorted, searched through, and manipulated in C# than arrays. That’s because of all of the built-in list functionalities in the language. Lists are used more often in C# than arrays are, but there are some instances where arrays can (or should) be used. That includes if your data is unlikely to grow very much or if you’re dealing with a relatively large amount of data that will need to be indexed into often. For more data please check out below link https://www.educba.com/c-sharp-array-vs-list/
6th Nov 2020, 8:33 PM
hossein B
hossein B - avatar