Blog Posts on programming visual studio csharp vb dot net
Percent:
How to solve multiple active datareader session in mvc3 C# by czetsuya's tech on May 6, 2012This problem commonly happens when you try to execute a query with a return type of IEnumerable then execute a second query with the result.Example, we have a table Animes:public IEnumerable GetAnimes() { return context.Animes;}//on the second part...
How to solve System.Security.SecurityException: That assembly does not allow partially trusted callers. by czetsuya's tech on Mar 29, 2012Recently I found myself in another shared hosting problem. Unfortunately, we are hosting our personalized-items/corporate give away website + wedding invitation (www.kalidadprintsandfavors.com) in godaddy.com. And I've just added a new feature where...
How to execute select count(*), field from table group by field in entity framework by czetsuya's tech on Mar 6, 2012As the title implies we will try to convert a native sql that group and counts the number of row.We will assume that you have a column quantity or number of items.//native queryselect count(*), fieldfrom tablegroup by field//entity frameworkvar query...
How to upload a file in an mvc3 c# ajax form by czetsuya's tech on Feb 27, 2012It's easy to upload file in a synchronous form, where you just post the file and read a HttpPostedFile variable in the server side:In plain html form, take note of the form enctype property://the view (index.cshtml)@using (Html.BeginForm("Upload", "F...
How to render a Chart object in a view in MVC3 by czetsuya's tech on Feb 13, 2012I was working on a project that requires showing a graph, fortunately there's already a built in graph helper in mvc3: http://www.asp.net/web-pages/tutorials/data/7-displaying-data-in-a-chart.Tried the tutorial in link above and was able to display t...
Elmah not logging, elmah.axd page is always null when using SqlErrorLog by czetsuya's tech on Feb 6, 2012First make sure that you're web.config file is setup properly and that you have defined elmah to handle the error in each controller. You can do that easily in c# mvc3 by using nuget and downloading elmah, elmah.corelibrary and elmah.contrib.mvc.&nbs...
How to read and write an object in a textfile in C# by czetsuya's tech on Jan 30, 2012Long time ago I've a requirement to read sms messages from device to be written in a text file. Before I learned to serialize an object, I was saving it in a file comma-delimited. That approach is working but sometimes it's a pain to keep track of wh...
Injection of Control in a C# Console Application by czetsuya's tech on Jan 26, 2012Now that I'm working with C# MVC3, I learned that it's easier to setup Injection of Control because of several available plugins that you can use straightly after install. For example the one I'm using is Unity.MVC, in Visual Studio 2010 you just hav...
Specify ON DELETE NO ACTION or ON UPDATE NO ACTION, or modify other FOREIGN KEY constraints by czetsuya's tech on Jan 11, 2012Have you encountered this error:"Introducing FOREIGN KEY constraint 'x_y_Target' on table 'z_UsersInRoles' may cause cycles or multiple cascade paths. Specify ON DELETE NO ACTION or ON UPDATE NO ACTION, or modify other FOREIGN KEY constraints."It app...
How to declare foreign key in Entity Framework by czetsuya's tech on Jan 11, 2012There are 2 ways to declare foreign key in entity framework. Assuming we have 2 entities aspnet_Users and Person, which are link via UserId from aspnet_Users.1.) class Person { public Guid UserId { get;set; } [ForeignKey("UserId")] public virtual...


