How many SQL Queries will be executed in the database through this EF

I have the following and want to know how many queries will be executed in the DB through this EF? private static dbContext dbc = new ProfileDBC(); private static IQueryable GetProfile(…

Seeding a table with Foreign key

I encountered a problem where I cant seed an SQL script since it has a foreign key constraint, I tried context.SaveChanges() but it isn’t working. Is there any way how this can be done? protected …

How to replace columns in a Queryable in a generic fashion without executing the Queryable

As an example, I have a Product entity, a ProductViewModel and a Label entity. Two of my product properties correspond to a label code rather than an actual value. So for example a Product’s Name is “…

How can I convert this sql query that reorders items in a database to linq?

I currently have a table where an item has a new order based on a column it’s being sorted by. The goal of the sql statement is to reorder the table based on that sort column. The SQL Command …

How can i Set decimal value in SQL (something like 10.12345678)

Can’t store decimal value in SQL. Want to store like decimal(2,8) Like 32.12345678 [Column(TypeName = “decimal(2,8)”)] [Display(Name = “Latitude”)] public decimal Latitude { get; set;…

Convert SQL query to Entity Framework which used AggregateFunctions and Where clause

How can I convert this query to Entity Framework? SQL query: SELECT Fullname, SUM(CoinCount+DiamondCount) AS GeneralPoint FROM Students, Groups WHERE Students.GroupId = Groups.Id AND Groups.Name = ‘…

SqlClient.SqlException: Invalid column name ClassNameId While fetching data from Fluent API

I am new to this EF,I am tring to fetch data from Sql Db table, and it gives me error like invalid classNameId error. public class ClassName { [Key] [Display(Name = “Id:”)] …

How can I get rid of having to prefix a WHERE query with ‘N’ for Unicode strings?

When searching for a string in our database where the column is of type nvarchar, specifying the ‘N’ prefix in the query nets some results. Leaving it out does not. I am trying the search for a …

Reference to multiple rows entity-framework?

How can I reference my column in table1 to multiple rows of another table in entity-framework work with custom navigation properties? this problem can be solved in SQL with a temp table which is …

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 …