asp.net 응용 프로그램에서 개체를 캐시하기위한 간단한 SQLCacheDependency를 구현하려고했습니다.SqlCacheDependency를 사용하여 Sql Server에서 간단한 select 쿼리에 대한 구독을 만들지 않습니다.
꽤 오래 동안 내 머리를 부러 뜨린 끝에 막 다른 골목에 휩싸인 것처럼 보이고 외부보기가 도움이 될 것이라고 생각했습니다.
SqlCommand cmd = new SqlCommand("SELECT UserID,FirstName,MiddleName,LastName,Mobile#,EmailID,FriendlyName,Phone#,AboutMe,Scrap#,JobPosting#,Testimonial#,Blog#,Views#,LastVisitedOn,CurrentAddress,City,State,Country,PermanentAddress,HomeTown,Occupation,CurrentEmployer,LanguageSpeak,LanguageWrite,CreatedOn,NeedJob,ProfileRank,Status,CurrentEmployerID,PictureID,ReferredBy,lat,Long,Zoom,Gender,PinCode,PersonalStatus,DOB,PreferredLanguage,EmploymentHistory,AboutFamily,LastSchoolName,HasCertificate,CertificateMonthLength,CertificateDescription,CertificateSchoolUserId,CallTimes,CertificateType,CertificateTypes,Skills FROM mydb.dbo.UserInfo where UserID=10277",con);
System.Web.Caching.SqlCacheDependency dependency = new System.Web.Caching.SqlCacheDependency(cmd);
con.Open();
try
{
SqlDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
seUserInfo = new UserInfo(reader, false);
this.Context.Cache.Add("Sean", seanUserInfo, dependency, System.Web.Caching.Cache.NoAbsoluteExpiration, System.Web.Caching.Cache.NoSlidingExpiration, System.Web.Caching.CacheItemPriority.Normal, new CacheItemRemovedCallback(ItemRemovedCallBack));
}
}
는 그러나이 항목은 즉시이 추가 될 때 캐시에서 제거됩니다. 이제 다른 가능한 원인 (데이터베이스에 ANSI NULLS ON을 설정하는 등)을 수정하는 데 많은 시간을 소비 한 후에 이제 벽에 부딪혔다. 는 SQL Server 프로파일에서, 나는 당신이 알 구독이 다음과 같은 텍스트 데이터
<qnev:QNEvent xmlns:qnev="http://schemas.microsoft.com/SQL/Notifications/QueryNotificationProfiler">
<qnev:EventText>subscription fired</qnev:EventText>
<qnev:SubscriptionID>0</qnev:SubscriptionID>
<qnev:NotificationMsg><qn:QueryNotification xmlns:qn="http://schemas.microsoft.com/SQL/Notifications/QueryNotification" id="0" type="subscribe" source="statement" info="invalid" database_id="0" sid="0x2EB2AC37F2E7FF468D5DE0B591029EE7"><qn:Message>26119019-fef7-47ee-ac82-3cb56313670d;9fbb5459-bde4-494b-9b7d-8347be2ee4cb</qn:Message></qn:QueryNotification></qnev:NotificationMsg><qnev:BrokerDlg>9B1E5573-A52F-E111-8152-005056C00008</qnev:BrokerDlg></qnev:QNEvent>
으로 발사되는 것을 볼 그 유형 = 가입 및 정보가 잘못 =. 이것은 나를 놀라게하는 것입니다. http://www.simple-talk.com/sql/t-sql-programming/using-and-monitoring-sql-2005-query-notification/과는 conditions specified for SqlDependency creation
을 준수하는 간단한 선택 문이 명확 "제출 명령 알림을 (예를 들어, INSERT 또는 UPDATE)를 지원하지 않는 문을 포함"할 때 발생 http://msdn.microsoft.com/en-us/library/ms189308.aspx에 따르면 그래서 내가 여기서 누락 된거야? 이것은 가장 간단한 시나리오이며 작동하지 않습니다!