Thanks
Mohammad Dayyan
Posts
-
Is it OK to implement Repository Pattern with Singleton in C# and EntityFramework ? -
Is it OK to implement Repository Pattern with Singleton in C# and EntityFramework ?Well :^) there are some reasons that you could find them with Google.
Eddy Vluggen wrote:
What do you think you will gain from the added patterns that's not there in EF?
my reasons : With Repository pattern we could hide DbContext(or ObjectContext) in UI layer for UI programmers and the they don't need to work with DbContext directly. otherwise, for each entity we have to write Update, Delete, Insert, ... methods. So with repository "Don't Repeat Yourself"
Eddy Vluggen wrote:
And why do you want a singleton, and not a simple static class?
Static class is an instance for all, and it has the same position in RAM of system. but Singleton has a static field and we can have different instances of our class, but we prevent coupling
-
Is it OK to implement Repository Pattern with Singleton in C# and EntityFramework ?As you know, in Entity Framework Repository Pattern we have new
DbContext(or object context)
in each entity's instance. Is it OK to implement Repository Pattern with Singleton to have the same DbContext in each entity's instance? If so, could you please post some references ? Thanks Read more about Repository Pattern : http://www.remondo.net/repository-pattern-example-csharp/[^] -
Expire Sessions via Session Id in ASP.Net C#?Well, Because I guess, it couldn't done in ASP.Net, I've written it in C# forum. AFAIK
Session.Abandon();
expire current session ! I wanna expire a session with session id -
Expire Sessions via Session Id in ASP.Net C#?I have an array includes list of users session id. I wanna expire all of them. Is it possible in ASP.Net (c#), if so, how ? else, how can I do it with C#? Thanks in advanced
-
Happy New Persian Year ;)Wow, do you now Persian?
-
Happy New Persian Year ;)Well, I haven't hear that so far ;P
-
Happy New Persian Year ;)Wow, New car ? Why new car !
-
Happy New Persian Year ;)Hi friends from all of the world, Today is the first day of 1391 persian year. Happy New Year :rose: In an old traditional ceremony, each Iranian family make an tablecloth that contains 7 God blessings that started with Seen(س). each of them is symbol of some God blessings : Apple(Sib), Vinegar(Serke), Sea-buckthorn(Senjed), Coin as plenty(Sekke), Verdure(Sabze), Clock as life(Sa-at), Samano(kind of dish prepared from the juice of germinating wheat) Read more about Haft-Seen[^]
-
What's your Recommendation?well, it's easier to carry 2kg against to carry 3,4,...kg
-
What's your Recommendation?Because, I need a portable laptop :)
-
What's your Recommendation?Do you have a specific model in mind ?
-
What's your Recommendation?I'm gonna buy a Laptop with weight lower than 2KG for ASP.Net programming. I prefer ASUS , because of my friends recommendations. Whats your recommendation ? :confused: It would be appreciate if you guide me to determine an specific model.
-
SQL Backing up with SMO & C# ?Ravi Bhavnani wrote:
Is the version of .NET on the XP system the same as that on your Win7 system?
The version that I've created the code based on was 9 but the version of destination system is 10, I created the project with 10 version but I receive below Exception :
Restore failed for Server '\\\\.\\pipe\\3F103E6E-3FD4-47\\tsql\\query'.
:(
-
{"Restore failed for Server '\\\\.\\pipe\\3F103E6E-3FD4-47\\tsql\\query'. "}Hi guys, I'm using the following code to restore a backup sql database with C# and SMO.
void RestoreDatabaseWithSMO(string sConnect, string dbName, string backUpPath)
{
using (SqlConnection cnn = new SqlConnection(sConnect))
{
cnn.Open();
cnn.ChangeDatabase("master");ServerConnection sc = new ServerConnection(cnn); Server sv = new Server(sc); if (!sv.Databases.Contains(dbName)) throw new Exception("this DataBase does not exist"); // Create backup device item for the backup BackupDeviceItem bdi = new BackupDeviceItem(backUpPath, DeviceType.File); // Create the restore object Restore resDB = new Restore(); resDB.PercentComplete += new PercentCompleteEventHandler(percentComplete); resDB.PercentCompleteNotification = 10; resDB.Devices.Add(bdi); resDB.NoRecovery = false; resDB.ReplaceDatabase = true; resDB.Database = dbName; resDB.Action = RestoreActionType.Database; // Restore the database resDB.SqlRestore(sv);//Exception }
}
but in the last line I got below exception !!!
{"Restore failed for Server '\\\\.\\pipe\\3F103E6E-3FD4-47\\tsql\\query'. "}
What's wrong with it ? Could you please guide me? Thanks
-
SQL Backing up with SMO & C# ?I'm using the following code to back up a SQL Database :
void BackupDatabase(string sConnect, string dbName, string backUpPath)
{
using (SqlConnection cnn = new SqlConnection(sConnect))
{
cnn.Open();
dbName = cnn.Database.ToString();ServerConnection sc = new ServerConnection(cnn); Server sv = new Server(sc); // Create backup device item for the backup BackupDeviceItem bdi = new BackupDeviceItem(backUpPath, DeviceType.File); // Create the backup informaton Microsoft.SqlServer.Management.Smo.Backup bk = new Backup(); bk.PercentComplete += new PercentCompleteEventHandler(percentComplete); bk.Devices.Add(bdi); bk.Action = BackupActionType.Database; bk.PercentCompleteNotification = 1; bk.BackupSetDescription = dbName; bk.BackupSetName = dbName; bk.Database = dbName; //bk.ExpirationDate = DateTime.Now.AddDays(30); bk.LogTruncation = BackupTruncateLogType.Truncate; bk.FormatMedia = false; bk.Initialize = true; bk.Checksum = true; bk.ContinueAfterError = true; bk.Incremental = false; // Run the backup bk.SqlBackup(sv); }
}
In my system (Win7 x64) it works fine but in destination system (WinXP SP3 x86) I receive the below error : Exception[^] How can I fix it ? Thanks. BTW: I installed
SQL Express 2008 R2
in destination system. -
DDL or CLR Trigger sample ?Hi guys, I have a Table (
TableTest
) in a Database (database1
) in SQLExpress 2008. I wanna to call a method in C# whenever something is inserted in the Table. Could you please guide me? It would be great if you post a sample code. Thanks. -
Showing an external image in Expression Blend or Visual Studio ?I have an image
lock.png
beside of my WPF exe file in theimages
folder. Now, I'm gonna load it into the WPF Project as an image. I've used the following XAML code:<Image Stretch="Fill" Source="pack://siteoforigin:,,,/images/lock.png" />
It works, but Expression Blend or Visual Studio doesn't show it when I'm working on the project. How can we show external images in these situations?
-
Loading an external image to WPF App ?Hi, I have an image
lock.png
beside of my WPF exe in theimages
folder. Now, I'm gonna load it into the WPF Project as the App's icon, I've use the following XAML code, but it doesn't work :Icon="images\lock.png"
How should I load an external image into a WPF application? Thanks
-
Is this code Horror ?Thanks a lot.