Tag: c#

What is the best way to handle DateTime in a Web Application?

I’ve been doing some research around on how to properly store and save the Date and Time in a Web Application but I couldn’t find a post that has a marked answer. I have a ASP.NET MVC website and I use C# for backend code and MS SQL for the database, let say you have […]

I have created a generic database class to call database (SQL Server) from C#

I am new to .net. Please help me what the things should I add here? How to add stored procedure? My aim is to keep DataAccess class in one project and use it in other project as .dll. In other project I just want to call dbclass and to add parameter, execute method only. Please […]

.NET C#: How to dislay foreign key property?

I have this model called Station and ServiceLevel. Station contains a foreign key called ServiceLevelId which refers to a primary key in the ServiceLevel table. But I can’t show the ServiceLevel properties which is a part of the Station. I can present the station properties in the view by writing: @Html.DisplayFor(model => model.Name) But it […]

After socket error, stored prodecude doesn't work well

I’m developing an Socket server using TCPListener running on a Windows Service, .NET Framework 4.6.1, Entity Framework 6.1.3 and C#. As database I’m using SQL Server Enterprise 2012 SP 2. I’m having problems with my database after I get a socket timeout on my socket client. Every time I get a socket timeout (or any […]

What's wrong with this LINQ?

I am using LINQ TO Entities & need to use Union operator. This is my raw sql query. (select DISTINCT c.DocumentId from [sDocument].[tDocumentStatus] c inner join [sDocument].[tTOCStructure] d on c.DocumentId = d.FolderID inner join [sDocument].[tAudit] e on c.DocumentId = e.FolderID where d.FolderType = 2 and d.isDeleted = 0 and d.ClientID = 9 and e.AuditDescriptionID != […]

FlyWay with interdependent databases

I’ve seen posts about FlyWay handling multiple databases but it all seems like it is for databases that are independent. As I understand it, FlyWay can only handle one database per instance so creating/cleaning database schemas are completely independent. Multiple datasources migrations using Flyway in a Spring Boot application Our problem probably stems from bad […]

Use of Async / Await to write to SQL using three Tasks

I have a program that reads from 7 different PLC’s at generally the same time using background threads. Using the 7 different reads, I am hoping to write to three different SQL tables. public static async void readReady() { if (Read1_complete && Read2_complete && BCS_complete == true) { await Task.Run(() => W1_SQL_Write.SQL_Write_Enabled()); } if (Read3_complete […]

FMTONLY in SqlBulkCopy.WriteToServer

When calling SqlBulkCopy.WriteToServer, I can see a bunch of SET FMTONLY ON and SET FMTONLY OFF However https://msdn.microsoft.com/en-us/library/ms173839.aspx says: Do not use this feature. This feature has been replaced by sp_describe_first_result_set (Transact-SQL), sp_describe_undeclared_parameters (Transact-SQL), sys.dm_exec_describe_first_result_set (Transact-SQL), and sys.dm_exec_describe_first_result_set_for_object (Transact-SQL). Is this still the correct .Net method to call for bulk inserts?

Asynchronous fire and forget in c#

Currently I am about to develop logging for a c# application into a SQL server table. I have a designated class called Logger that has a static method writeToLog(). I just want to call that static function without block the calling thread. How is this possible in C# clean and fast? The functions don’t return […]

Lost order after Take/Skip in Entity Framework

I have a query in EF which takes information from various tables. I would order on the basis of certain fields in this way: query = query.OrderBy(x=>new {x.Cde_Conto,x.Data_1,x.Data_2}); If i do query.TotraceQuery(); in sql server i get the desired result. but I have to do an extra step..given that i have to show only a […]

MS SQL Server is a Microsoft SQL Database product, include sql server standard, sql server management studio, sql server express and so on.