entity framework view not refreshing

November 23, 2015

https://christianarg.wordpress.com/2013/06/13/entityframework-refreshall-loaded-entities-from-database/

AsNoTracking

http://stackoverflow.com/questions/22177491/how-to-force-entity-framework-to-always-get-updated-data-from-the-database


Sharepoint notes : Sharepoint 2013 in maintenance mode

November 16, 2015

http://blog.portiva.nl/2014/06/25/sharepoint-2013-site-stuck-in-read-only-mode/

https://nasironline.wordpress.com/tag/we-apologize-for-any-inconvenience-but-weve-made-the-site-read-only-while-were-making-some-improvements/

Issue : “We apologize for any inconvenience, but we’ve made the site read only while we’re making some improvements.”

So I woke up this morning finding one of our SharePoint 2013 sites in read-only mode. When I browsed the site I got the following message: “We apologize for any inconvenience, but we’ve made the site read only while we’re making some improvements.”

DH-ReadOnly-Screen1

On further investigation I noticed that the nightly backup of this specific site collection did not complete successfully”. When you backup a Site, SharePoint places the site in read-only mode. But since my backup hanged the site never got out the read-only mode.

When you check the site in the Site Collection Quota and Locks Screen you’ll find all options greyed out:

DH-ReadOnly-Screen2

I checked the SPSite.MaintenanceMode setting and it was set to true.

DH-ReadOnly-Screen6

So I first turned to PowerShelll trying to set the lockstate to unlocked. And although I did not get an error, the site was still locked. So I tried good old STSADM. Operation completed successfully but still LOCKED.

DH-ReadOnly-Screen3

DH-ReadOnly-Screen4

Luckily since the April 2013 CU update for SharePoint 2013 we now have the SpsiteAdministration.ClearMaintenanceMode method. So we can clear the flag with the flowing two lines:

$site = new-object Microsoft.SharePoint.Administration.SPSiteAdministration(‘http://intranet.demo.local’)
$site.ClearMaintenanceMode()

DH-ReadOnly-Screen7

and your site is out of maintance mode again!

DH-ReadOnly-Screen8


Sharepoint notes : Invalid characters in filenames

October 30, 2015

As per share point, the below are invalid character in a file name which we are already handing from UI.
” # % & * : ? \ / { | } ~

the below things about share point file names which we have to implement across all the processes.

• Do not use: ” # % & * : ? \ / { | } ~
• File names cannot be longer than 128 characters
• Do not use the period character consecutively in the middle of a file name.
• You cannot use the period character at the end of a file name
• You cannot start a file name with the period character
• Many other symbols are not recommended such as $^()-_=+[]`! (other international currency symbols and international symbols should be avoided in site names, but some are more acceptable in file names. Ascii is preferred when possible.


Sqlserver notes : Issue – The row value(s) updated or deleted either do not make the row unique or they alter multiple rows(2 rows).

October 19, 2015

http://allenbuckley.com/blog/the-row-values-updated-or-deleted-either-do-not-make-the-row-unique-or-they-alter-multiple-rows/

SET ROWCOUNT 1
DELETE FROM Table1
WHERE col1 = ‘0001’


Sqlserver notes

October 16, 2015

Before deleting data from production server follow these steps. Its a good practice

select * from WriteOff_ReworkUsers
where Ref_ID in (189538,201177,201185,203533,203534,203563,203567)

begin tran
delete from WriteOff_ReworkUsers
where Ref_ID in (189538,201177,201185,203533,203534,203563,203567)
rollback tran

begin tran
delete from WriteOff_ReworkUsers
where Ref_ID in (189538,201177,201185,203533,203534,203563,203567)
commit tran


Entity framework stored procedure always returning int

October 5, 2015

http://www.devtoolshed.com/using-stored-procedures-entity-framework-scalar-return-values

http://stackoverflow.com/questions/18245567/stored-procedure-returns-int-instead-of-result-set

I have a stored procedure that contains dynamic select. Something like this:

ALTER PROCEDURE [dbo].[usp_GetTestRecords]
–@p1 int = 0,
–@p2 int = 0
@groupId nvarchar(10) = 0
AS
BEGIN
SET NOCOUNT ON;

DECLARE @query NVARCHAR(max)

SET @query = ‘SELECT * FROM CUSTOMERS WHERE Id = ‘ + @groupId
/* This actually contains a dynamic pivot select statement */

EXECUTE(@query);
END

Answer :

SET FMTONLY OFF

or


Sqlserver notes: Minus operator in Oracle – Sqlserver Except or Not Exists

September 30, 2015

http://www.sqlservercurry.com/2011/01/minus-keyword-in-sql-server.html

MINUS operator (in oracle) is used to subtract the rows which are available in the second result, from the first result set. SQL Server does not have a built-in MINUS keyword, but in SQL Server, it’s equivalent is the EXCEPT operator or using NOT EXISTS

Here’s an example. Consider the following tables

DECLARE @table1 table(a int, b int)
DECLARE @table2 table(a int, b int)

TEST DATA

INSERT INTO @table1
SELECT 1 as a, 2 as b
UNION ALL
SELECT 1 as a, 2 as b
UNION ALL
SELECT 11 as a, 12 as b
UNION ALL
SELECT 13 as a, 12 as b

INSERT INTO @table2
SELECT 1 as a, 21 as b
UNION ALL
SELECT 1 as a, 12 as b
UNION ALL
SELECT 1 as a, 112 as b
UNION ALL
SELECT 13 as a, 12 as b

Using EXCEPT

SELECT * FROM @table1
EXCEPT
SELECT * FROM @table2
Using NOT EXISTS

SELECT DISTINCT t1.* FROM @table1 as t1
WHERE NOT EXISTS
(SELECT * from @table2 as t2
WHERE t1.a=t2.a and t1.b=t2.b)

NOT EXISTS also has the same functionality of EXCEPT operator i.e. retrieving the rows from the first table, which are not available in the second result set


Follow

Get every new post delivered to your Inbox.