C#

General discussions about the c# language, Squirrels | gist.gi...
Oct 2 16:24
Thanks, that seems to make some more sense. I've only started enabling nullable in the project and still wrapping my head around it.
Oct 2 16:12
If I have nullable enabled in a project, I get an error that I have duplicate methods when I have one method use string parameter and another use string?. This doesn't happen with other types like bool and bool? and I'm not sure why. Is string still considered a nullable type?
May 14, 2022 18:09
I see a lot of example code that uses both SignInManager<T> and UserManager<T>. Is there reason to keep them separate as SignInManager has a UserManager property? For example:
_userManager.FindByEmailAsync(login.Email); vs _signInManager.UserManager.FindByEmailAsync(login.Email);
Dec 3, 2018 20:31
@juanvan Yeah, Im using that linked solution as a way to clean up the data after. The problem trying to do it in the SQL statement is I have a lot of tables to select and it's a pain to write SELECT RTIM(Vendorname) AS Vendorname, RTIM(Vendoraddress1) AS Vendoraddress1, RTRIM(Vendoraddress2) AS Vendoraddress2 .... etc. I was wanting to just do SELECT * FROM VendorTable
Dec 3, 2018 19:44
I have a function that loops through all tables and all rows and for every string type column does .ToString().Trim(), but was wondering if there was a way for the DataAdapter to do it at the time of the filling
Dec 3, 2018 19:44
I was hoping there's a way to auto do that when querying as this entire database uses CHAR for any string types.
Dec 3, 2018 19:38
Does anyone if there's a quick way to have an OdbcDataAdapter auto trim the ending blank spaces that come from a CHAR column?
Sep 19, 2018 19:26
Does anyone know why Dataset ignores the XmlRoot attribute when using WriteXml?
Sep 19, 2018 17:53
Does anyone know if it's possible to deserialize an XElement into a Typed DataTable? My attempts just give me an empty table.
Sep 18, 2018 15:36
Is there an easy way to deserialize an XElement if the name of the element isn't the same as the class i'm trying to deserialize to, but the properties and the elements in the XElement are the same?
Sep 4, 2018 14:22
@milleniumbug Yes, was going to do that. I feel like I have a lot of work ahead of me.
Sep 4, 2018 14:17
I'm still new to Git and have only been using it on my own. I recently inherited a bunch of projects from a person no longer at the company who was just making copies and renaming the main folder (V1.5, V1.6, V1.7, etc). Is there a way in Git to combine these either as separate commits or branches?
Jul 3, 2018 14:54
@Squirrelkiller Yeah, it seems that most of the results are issues with comparing semantically similar, but with my unit test they are actually the same, so I thought I may be missing something with unit testing as I am still learning
Jul 3, 2018 14:47
@Squirrelkiller It returns true
Jul 3, 2018 14:40
I created a UnitTestProject in Visual Studio
Jul 3, 2018 14:39
@ntohl Not sure what fluentassertion is so Im going to say no.
Jul 3, 2018 14:37
I'm just starting to learn unit testing and having a problem comparing two XElements, but I'm not sure why the Assert fails. The message shows Assert.AreEqual failed. Expected:<<PrefillAccountRef>
<FullName>full-name-value</FullName>
</PrefillAccountRef>>. Actual:<<PrefillAccountRef>
<FullName>full-name-value</FullName>
</PrefillAccountRef>>. but they look the same to me
Apr 4, 2018 20:03
Each of these account types have a numeric value 0-14, which for my query I need to include in a CSV list
Apr 4, 2018 20:03
It's a list of account types (Bank, CreditCard, CurrentAsset, CurrentLiability, Income, OtherIncome) where the user can select one or more selections. There's also some pre-defined selections (like AllIncomeAndExpense or BalanceSheet) which is a combination of account types.
Apr 4, 2018 19:44
Apr 4, 2018 19:43
Do you have an example of how the struct would work? Im not visualizing it well for my needs?
Apr 4, 2018 19:36
I don't care about the efficiency, I just didn't like having to change code in two places if things change
Apr 4, 2018 19:34
I was looking into BitArray, but Im not seeing how it leads to friendly 'flag' names
Apr 4, 2018 17:51
It feels 'bad' as the logic is decoupled from the enum, so if we change the enum, we have to make sure to change the function as well.
Apr 4, 2018 17:51
Anyone have any suggestions on the way this enum flags is implemented?
https://gist.github.com/ttrudeau/8496a0945211f605266f69b6529dce09
Mar 12, 2018 13:36
Does anyone know if execution is faster by creating one MemoryStream and using MemoryStream.Write in a loop vs creating a new MemoryStream each time in a loop? I would think that garbage collection would happen more often creating a new memory stream each time, but I am not sure if MemoryStream.Write would also cause that?
Mar 7, 2018 18:48
This is what I was thinking, but the empty abstract class 'feels' wrong: gist.github.com/anonymous/030b8a6ac79a1e99cfda51c98e8ea7a7
Mar 7, 2018 18:47
Is there a design pattern where a class has different members? I'm creating a filter class that can have only one of these three options; (1 or more AccountType) OR (1 or more IDs) OR (1 or more Names). I'd like to be able to have one function that takes one of these three filters.
Mar 5, 2018 16:12
@MikeTheLiar Like create a dictionary of the names and the highest value?
Mar 5, 2018 16:10
Faster as in execute faster as I have to do this often
Mar 5, 2018 16:09
No, the sequence won't be in order, but the name will always be the same
Mar 5, 2018 16:08
I was thinking about Regex, but haven't tried it
Mar 5, 2018 16:07
If I have a list of names with numbers at the end (John1, John2, John3,...John55) and I want to get the next name in sequence, is there a faster/better way than this: gist.github.com/ttrudeau/fae645c0e6a7a847b21aec9f57769ac0
Mar 1, 2018 17:03
Doh. Nevermind. It's throwing an exception that is just getting ignored when setting the first data binding, so it never reaches the second data binding line.
Mar 1, 2018 16:59
It's odd as the code works for the first DateTime, but not the second. I put a breakpoint in before the dialog closes and the debugger shows a default value for the ToDate.
Mar 1, 2018 16:58
I'm having problems databinding a DateTime to a DateTimePicker. I have two DTP and two DateTime properties. The first DateTime gets updated with changes to the DateTimePicker, but the second one doesn't.
Feb 28, 2018 18:34
Does anyone know or have a good resource on how to properly implement IDisposable with a COM object so the class doesn't generate RCW errors?
Feb 27, 2018 15:50
I guess I could convert to string and then compare against "None"?
Feb 27, 2018 15:49
public static bool IsSet(this Enum value) { if(value == 'None') return false; else return true; }
Feb 27, 2018 15:48
I was wanting to use a more generic test as I have about 50 different enums and didn't want to write specific code for each one
Feb 27, 2018 15:46
Is there a way to check any enum to see if is set to a value of 'None'? Would I need to set my enums with None = 0 and then do if(enumValue.Equals(0))
 

ASP.NET MVC

Merged into C# chat on 4/19/21. Post messages there please as ...
Apr 2, 2021 10:33
Are Controllers/Actions considered part of the ASP .NET Pipeline/Middleware? Is this where the term "endpoints" comes from because the controller/action is the end of the pipeline?
 

SQL

Got a SQL question? Any SQL flavor here, just ask. Indicate yo...
Dec 27, 2018 13:59
I just wish whoever designed this table would have just added a column to reference the parent record...
Dec 27, 2018 13:58
I do have a column that tells me if this record is a potential parent. That will be 1 if it MIGHT have children or 0 for any child record
Dec 27, 2018 13:57
SQL Server
Dec 27, 2018 13:57
The CLIENT_ID column is always unique and will have either a number, like 4567, or if the record is for a child it will always have a letter following the parent number
Dec 27, 2018 12:36
I only get a count of 1 for everyone
Dec 27, 2018 12:35
I've tried this: SELECT CLIENT_ID, COUNT(*) AS CHILDREN FROM CLIENT GROUP BY CLIENT_ID HAVING CLIENT_ID LIKE CONCAT(CLIENT_ID, '%')
Dec 27, 2018 12:35
Is there a way to get the count where of the columns that are LIKE a column? The CLIENT_ID has a varchar, and any children have the same CLIENT_ID but with a letter at the end (4567 is a parent, 4567A is the first child, 4567B is the second, etc). I am trying to get the count of children for each parent.