I have a table in SQL Server (current data) Total Over Time of EmpId 1001 in January-2020 is 3hrs 24 min I want to distribute/add 3hrs 24min randomly between 1-jan-20 to 31-jan-20 to OutTime column …
Tag: asp.net-mvc
Custom select Entity Framework
I want to perform a custom select with Entity Framwork and can not make it good would you help me to figure this SQL select with Entity Framework SELECT DISTINCT Departments.Dept_ID, Departments….
How to merge two rows having same data?
i have a table with some data i want to merge the identical row i.e.as shown in image two identical rows having same tDateWorked,empid,jobid i want to merge this records so that OT and ST should …
I need to migrate data from one old table to a new table by storing appropriate CityId instead CityName
I’m migrating data from one table to another table in SQL Server, In this process what I need to do is “I have 10 columns in old table one column is ‘CityName’ which is varchar and in the new table, I …
Get FileStream size (sql server) by mvc app context asp net mvc
I would like if .net (asp.net mvc) provides possibility to get size of FileStream having DbContext. As I did research so far I can: 1) SELECT SUM(DATALENGTH(‘ColumnName’))FROM Table 2) SELECT …
Generic repository with Dapper
I’m trying to build a generic repository with Dapper. However, I have some difficulties to implement the CRUD-operations. Here is some code from the repository: As you can see, my delete-method takes a TEntity as parameter which is a parameter of type class. I call my Delete-method from my UserRepository like this: The thing is that I can’t write entity.Id
System.Data.SqlClient.SqlException (0x80131904): Invalid column name
I am getting this error while trying to execute the attached code. Please help. I am getting values as list array in controller method successfully but when I try to read data from sql database I am getting error. Controller method: Execption:- Answer Since you are using inline SQL, every value within dogCSV string that’s comma separated needs a single
EF – AND NOT EXISTS (SELECT 1 …) with Entity Framework
I am trying to run this query using Entity Framework in my ASP.NET MVC project but I am not succeeding. Could anyone help me do this using LINQ? TABLES: Answer The direct equivalent LINQ construct of SQL NOT EXISTS (…) is !Any(…). So translates to
How do you write a parameterized where-in raw sql query in Entity Framework
How do you write a parameterized where-in raw sql query in Entity Framework? I’ve tried the following: But as expected, it throws an error on DateParam because it’s expecting a single value. Answer This isn’t a problem specific to entity-framework, you can solve it by generating your own parameter names dynamically. The resulting query sent to SQL-Server will look like
efficient way to implement paging
Should I use LINQ’s Skip() and Take() method for paging, or implement my own paging with a SQL query? Which is most efficient? Why would I choose one over the other? I’m using SQL Server 2008, ASP.NET MVC and LINQ. Answer Trying to give you a brief answer to your doubt, if you execute the skip(n).take(m) methods on linq (with