How to True Use SqlDataReader asp.net c#
Hi,I use sqldatareader. But ı'm searching and found multiple using. I using sqldatareader and gridview datasource,bind. No if no while and this status working.But used like this in other sources....
View Articlegeneric repository and multiple column sort
this is very simple way to sort by multiple column.var qry = ctx.DestinationTimings.Where(x => x.DestinationID == this.ID) .OrderBy(t => t.Date ?? DateTime.MaxValue) .ThenBy(t => t.DayOfWeek)...
View ArticlePlease help me with using FOR loop on Entity
Sorry to bother... I'm learning c# and found a problem that I don't know how to resolve... its about Entity connection to a local table... now I can loop using FOREACH... by curiosity I tried to make...
View ArticleLINQ Best use for selectmany
please show me small example of selectmany which guide me in which situation people use selectmany. thanks
View ArticleLINQ query to get the top 1 from each group by first date
I have the SQL query .. How to do the same in linq;WITH cte AS ( SELECT [TYPE] ,[SEC_ID] ,[STDATE] ,[FILENM], ROW_NUMBER() OVER (PARTITION BY [SEC_ID] ORDER BY [STDATE] asc) AS rn FROM [CFileData] )...
View ArticleUpdating an entity with GraphDiff and ignore one or more properties
Hi, I use RefactorThis.GraphDiff library to edit an entity with all of related entities. How can I ignore one or more specific columns when I use this library?DataContext.UpdateGraph(entity, x =>...
View ArticleJoin three tables using LINQ Query
Hello all,I got stuck on how to write LINQ for joining three different tables as follows:- tblStudent: student_id, school, class, grade- tblAwards: school, class, grade, account_number- tblAccount:...
View ArticlePass variable as parameter to where clause in Linq
Hi All, How to pass one variable value as parameter to where clause in Linq? Like In ado.net we using parameter to avoid sql injection. Below i providing my code. SettingsManager manager = new...
View ArticleEF Core filtering + paging with child entities
I want to perform 1 query (to SQL Server) using EF Core where I have to filter on a child entity and also apply paging. See my (sample) data model below:I want to retrieve all data (customers, orders...
View ArticleLinq Query to Extract Detail from multiple rows of same ID from one table
Hi, I need to extract data from multiple rows of the same ID from one table.The Student Table:ID | FName | LName ======================== 1 | ABC | XYZ 2 | MNA | PQRProgram TableID | Program...
View ArticleMultiple Database Problem 2
Hi All,I'm looking for some general advice on writing SQL statements to solve a problem with data being stored in multiple databases. Without going into too much detail, the company I work for...
View ArticleConvert T-SQL to LINQ
Hi all,I got stuck in converting T-SQL to LINQ as followsselect DISTINCT [ACCOUNT] from [dbo].[BUDGET] b, [dbo].[OWNER] o where b.FUND = o.FUND AND b.DEPARTMENT = o.DEPARTMENT AND b.PROGRAM = o.PROGRAM...
View ArticleDecimal Precision, scale
Hello I am using .Net CoreI want to add a property to my model pubic decimal ContractId {get;set;}and create relation to Contract Table Primary Key so I added public virtual Contracts Contract...
View ArticleHow to solve this error
"ExceptionMessage": "The entity or complex type 'WebApiStandAloneProject.Models.Student' cannot be constructed in a LINQ to Entities query.",public IHttpActionResult GetAllStudent(bool includeAddress =...
View ArticlePassing Date Parameter as SqlCommand Parameter in C#
How to pass Date parameter from asp.net C# to sql server using sql command parametersError i am getting is "Invalid cast from 'DateTime' to 'Int32'.Couldn't store <10/3/2017 12:00:00 AM> in Date...
View ArticleMoving from EF db First to EF Core
HiI have a little app using EF db first and I want to move it to EF Core.I've used my models classes generated previously.but I got some errors: The entity type ... requires a key to be definedorSQL...
View Articlehow to alter add more pages in mvc project
If I have created a web app using mvc and entity framework and If I want to modify some functionalities and add some relationships with tables then what should I do.Thanks
View ArticleMethod 'Boolean Equals(System.String, System.StringComparison)' has no...
Hi peeps,I have a table that is defined as follows:Id(pk) int CountyName nvarchar(100)Before I insert a new CountyName into the table, I would like to ensure that its a unique record by using the...
View Articlesituation need order by with like , or any suggestion
select table_name from dba_tab_columns where column_name like '%password%' order by TABLE_NAMEOnly for knowledge BTW,I am fetching the record by id, the grid result was showing the 300 records.I want...
View ArticleProblem in Converting object to json
Hi friends :)when i use this query to return json,everything is ok! var Result2 = (from r in Result join l in db.tbl_lessons on r.idLesson2 equals l.idLesson where r.idLesson2 == l.idLesson ||...
View Article