To learn about how we can use stored procedure with Entity framework code first, jalpesh vadgama has written a very good blog post here.
Thanks jalpesh vadgama.
Thanks jalpesh vadgama.
Check how much technoledge do you have?? Enjoy The world of "Technoledge". This blog is all about Technology. Latest Tech-news, Tips & Tricks, Fun Stuffs for Internet, Computer, Site etc. If you have something more technoledge, please share it with others by posting here. If any one want to post an article on this site or he want authors rights please contact me at vihangshah.it@gmail.com.
SELECT Column1FROM Table1WHERE Column1 = 'casesearch'SELECT Column1FROM Table1WHERE Column1 COLLATE Latin1_General_CS_AS = 'casesearch'ALTER TABLE Table1ALTER COLUMN Column1 VARCHAR(20)COLLATE Latin1_General_CS_ASEXEC sp_help DatabaseName<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>pclass</Title>
<Shortcut>pclass</Shortcut>
<Description>Code snippet for public class</Description>
<Author>Microsoft Corporation</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
<SnippetType>SurroundsWith</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Declarations>
<Literal>
<ID>name</ID>
<ToolTip>Class name</ToolTip>
<Default>MyClass</Default>
</Literal>
</Declarations>
<Code Language="csharp"><![CDATA[public class $name$
{
$selected$$end$
}]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>propmatchname</Title>
<Shortcut>propmatchname</Shortcut>
<Description>Code snippet for property and backing field with matching name</Description>
<Author>Microsoft Corporation</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Declarations>
<Literal>
<ID>type</ID>
<ToolTip>Property type</ToolTip>
<Default>int</Default>
</Literal>
<Literal>
<ID>property</ID>
<ToolTip>Property name</ToolTip>
<Default>MyProperty</Default>
</Literal>
</Declarations>
<Code Language="csharp"><![CDATA[private $type$ m_$property$;
public $type$ $property$
{
get { return m_$property$;}
set { m_$property$ = value;}
}
$end$]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
SET NOCOUNT OFF
GO
declare @Text_To_Search nvarchar(max)
declare @TableName nvarchar(max)
declare @ColName nvarchar(max)
declare @CMD nvarchar(max)
declare @DBname nvarchar(max)
declare @Single_DB_Only bit
set @Text_To_Search = 'SOMETHING' -- Enter the Text here which you want to search
set @Single_DB_Only = 1 -- If @Single_DB_Only = 0 then the search will be in only one database
if @Single_DB_Only = 1
set @DBname = 'MY_DATABASE' -- Enter Database Name in which you want to search
/* ********************** Validation ********************** */
IF @Single_DB_Only = 1 AND NOT EXISTS(SELECT name FROM [master].[sys].[databases] WHERE name = @DBname)
BEGIN
PRINT 'Please enter valid database name'
RAISERROR('Please enter valid database name', 20, -1) WITH LOG
END
/*-- ********************** Validation ********************** */
if exists(select * from [master].[dbo].sysobjects where xtype = 'U' and [Name] = 'MY_INFO_ALL_TABLES')
drop table [master].[dbo].MY_INFO_ALL_TABLES
create table [master].[dbo].MY_INFO_ALL_TABLES (TableName nvarchar(max), ColName nvarchar(max))
if exists(select * from [master].[dbo].sysobjects where xtype = 'U' and Name = 'MY_INFO')
drop table [master].[dbo].MY_INFO
create table [master].[dbo].MY_INFO (DBName nvarchar(max), TableName nvarchar(max), ColName nvarchar(max), FieldValue nvarchar(max))
if @Single_DB_Only = 0
Begin
declare CUR_DB cursor for select name from [master].[sys].[databases] where name not in('master','tempdb', 'model','msdb','tempdb') and state = '0'
open CUR_DB
fetch next from CUR_DB into @DBname
while @@FETCH_STATUS = 0
Begin
print @DBNAME
set @CMD = 'insert into [master].[dbo].MY_INFO_ALL_TABLES (TableName, ColName) select T1.Name as TableName , T0.Name as ColName from [{3}].sys.syscolumns T0 inner join [{3}].sys.sysobjects T1 on T0.id = T1.id where T1.xtype = ''U'' and T0.Name not like ''MY_TABLES%'' '
set @CMD = replace(@CMD,'{3}',@DBname)
-- print @CMD
exec (@CMD)
declare CUR cursor for select TableName , ColName from [master].[dbo].MY_INFO_ALL_TABLES
open CUR
fetch next from CUR into @TableName, @ColName
while @@FETCH_STATUS = 0
Begin
set @CMD = 'insert into [master].[dbo].MY_INFO (DBName,TableName,ColName,FieldValue) select ''{3}'',''{1}'',''{0}'', cast({0} as nvarchar) from [{3}].dbo.{1} where {0} like ''%{2}%'' '
set @CMD = replace(@CMD,'{0}',@ColName)
set @CMD = replace(@CMD,'{1}',@TableName)
set @CMD = replace(@CMD,'{2}',@Text_To_Search)
set @CMD = replace(@CMD,'{3}',@DBname)
-- print @CMD
exec (@CMD)
fetch next from CUR into @TableName, @ColName
End
close CUR
deallocate CUR
fetch next from CUR_DB into @DBname
End
close CUR_DB
deallocate CUR_DB
End
Else
Begin
print @DBNAME
set @CMD = 'insert into [master].[dbo].MY_INFO_ALL_TABLES (TableName, ColName) select T1.Name as TableName , T0.Name as ColName from [{3}].sys.syscolumns T0 inner join [{3}].sys.sysobjects T1 on T0.id = T1.id where T1.xtype = ''U'' and T0.Name not like ''MY_TABLES%'' '
set @CMD = replace(@CMD,'{3}',@DBname)
-- print @CMD
exec (@CMD)
declare CUR cursor for select TableName , ColName from [master].[dbo].MY_INFO_ALL_TABLES
open CUR
fetch next from CUR into @TableName, @ColName
while @@FETCH_STATUS = 0
Begin
set @CMD = 'insert into [master].[dbo].MY_INFO (DBName,TableName,ColName,FieldValue) select ''{3}'',''{1}'',''{0}'', cast({0} as nvarchar) from [{3}].dbo.{1} where {0} like ''%{2}%'' '
set @CMD = replace(@CMD,'{0}',@ColName)
set @CMD = replace(@CMD,'{1}',@TableName)
set @CMD = replace(@CMD,'{2}',@Text_To_Search)
set @CMD = replace(@CMD,'{3}',@DBname)
-- print @CMD
exec (@CMD)
fetch next from CUR into @TableName, @ColName
End
close CUR
deallocate CUR
fetch next from CUR_DB into @DBname
End
select * from [master].[dbo].MY_INFO
GO
CREATE TABLE [Category]( [CatId] [int] IDENTITY(1,1) NOT NULL, [PCatId] [int] NULL, [CatName] [varchar](50) NULL, CONSTRAINT [PK_Category] PRIMARY KEY CLUSTERED ( [CatId] ASC )) GO
Insert into [Category] ([PCatId],[CatName]) values (0,'Cat1'); Insert into [Category] ([PCatId],[CatName]) values (0,'Cat2'); Insert into [Category] ([PCatId],[CatName]) values (1,'Cat3'); Insert into [Category] ([PCatId],[CatName]) values (1,'Cat4'); Insert into [Category] ([PCatId],[CatName]) values (2,'Cat5'); Insert into [Category] ([PCatId],[CatName]) values (2,'Cat6'); Insert into [Category] ([PCatId],[CatName]) values (0,'Cat7'); Insert into [Category] ([PCatId],[CatName]) values (7,'Cat8'); Insert into [Category] ([PCatId],[CatName]) values (7,'Cat9'); Insert into [Category] ([PCatId],[CatName]) values (7,'Cat10'); Insert into [Category] ([PCatId],[CatName]) values (8,'Cat11'); Insert into [Category] ([PCatId],[CatName]) values (8,'Cat12'); Insert into [Category] ([PCatId],[CatName]) values (8,'Cat13'); GO
declare @catId int = 8;
-- select * from Category;
WITH hierarchy AS (
SELECT c1.CatId,
c1.CatName,
c1.PCatId,
CAST(NULL AS VARCHAR(50)) AS parentname
FROM Category c1
WHERE c1.PCatId = 0
UNION ALL
SELECT c2.CatId,
c2.CatName,
c2.PCatId,
y.CatName
FROM Category c2
JOIN hierarchy y ON y.CatId = c2.PCatId)
SELECT s.CatId,
s.CatName,
s.PCatId,
s.parentname
FROM hierarchy s
where s.PCatId = @catId OR s.CatId = @catId
order by s.PCatId
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
| <script type="syntaxhighlighter" class="brush: csharp"><![CDATA[// Commentpublic class Testing {public Testing() {}public void Method() {/* Another Commenton multiple lines */int x = 9;}}]]></script> |
1
2
3
4
5
6
7
8
9
10
11
| // Commentpublic class Testing { public Testing() { } public void Method() { /* Another Comment on multiple lines */ int x = 9; }} |
1
2
3
4
5
6
7
8
9
10
11
12
| <pre class="brush: csharp">// Commentpublic class Testing {public Testing() {}public void Method() {/* Another Commenton multiple lines */int x = 9;}}</pre> |
1
2
3
4
5
6
7
8
9
10
11
| // Commentpublic class Testing { public Testing() { } public void Method() { /* Another Comment on multiple lines */ int x = 9; }} |
1
| static Dictionary<int, List<Delegate>> _delegate = new Dictionary<int, List<Delegate>>(); |