ok thank you for your answer , thank to that i fount this http://aspnet.codeplex.com/releases/view/41742 T_T
which was what i was searching for after i had seen it long ago in some blog post
but , i just read some of the readme files , and they say i need to addreference to web.mvc dll , doesnt that override the current web.mvc dll ? should i really use thier own one?
The ModelCopier from MVC Futures is a meant for very simple scenarios, such as the one you have. If you need something more complex, you may want to try the excellent AutoMapper library.
Marked as answer by strictDesign on May 04, 2010 06:04 AM
I think you should also need to aware about, Shallow Copy, Deep Copy in .NET
"And whoever is removed away from the Fire and admitted to Paradise, he indeed is successful." (The Holy Quran)
Excellent Windows VPS Hosting Imran Baloch MVP, MVB, MCP, MCTS, MCPD
Marked as answer by strictDesign on May 04, 2010 06:04 AM
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
A a1 = new A { S1 = "1", S2 = "2", S3 = "3" };
A a2 = (A)a1.Clone();
a1.S1 = "4";a1.S2 = "5";a1.S3 = "6";
Console.WriteLine(a1.S1);
Console.WriteLine(a1.S2);
Console.WriteLine(a1.S3);
Console.WriteLine(a2.S1);
Console.WriteLine(a2.S2);
Console.WriteLine(a2.S3);
Console.ReadLine();
}
}
public class A
{
public string S1 { get; set; }
public string S2 { get; set; }
public string S3 { get; set; }
public object Clone()
{
return this.MemberwiseClone();
}
}
}
"And whoever is removed away from the Fire and admitted to Paradise, he indeed is successful." (The Holy Quran)
Excellent Windows VPS Hosting Imran Baloch MVP, MVB, MCP, MCTS, MCPD
Marked as answer by strictDesign on May 04, 2010 06:04 AM
strictDesign
Member
82 Points
114 Posts
Fast way to copy a model ? -.-
May 03, 2010 06:44 PM|LINK
is there any fast way to copy a model instade of doing the following ? -.-;
public override void Edit(Video videoToEdit) { Video e = Get(videoToEdit.id); e.Class = videoToEdit.Class; e.Description = videoToEdit.Description; e.Duration = videoToEdit.Duration; e.Embed_URL = videoToEdit.Embed_URL; e.Match_Type = videoToEdit.Match_Type; e.Player_Name = videoToEdit.Player_Name; e.Post_Date = videoToEdit.Post_Date; e.Rating = videoToEdit.Rating; e.Team_Size = videoToEdit.Team_Size; e.Title = videoToEdit.Title; e.Uploader_ID = videoToEdit.Uploader_ID; e.Uploader_Name = videoToEdit.Uploader_Name; e.Views = videoToEdit.Views; }vn_nilesh@ho...
Member
542 Points
85 Posts
Re: Fast way to copy a model ? -.-
May 03, 2010 07:46 PM|LINK
You can use an object mapper tool like Automapper to map data between two objects.
http://automapper.codeplex.com/
Nilesh
http://nileshgule.blogspot.com
http://twitter.com/nileshgule
http://www.facebook.com/nilesh.gule
Please mark this as "ANSWER" if it helps you
strictDesign
Member
82 Points
114 Posts
Re: Fast way to copy a model ? -.-
May 03, 2010 09:42 PM|LINK
ok thank you for your answer , thank to that i fount this http://aspnet.codeplex.com/releases/view/41742 T_T
which was what i was searching for after i had seen it long ago in some blog post
but , i just read some of the readme files , and they say i need to addreference to web.mvc dll , doesnt that override the current web.mvc dll ? should i really use thier own one?
levib
Star
7702 Points
1099 Posts
Microsoft
Re: Fast way to copy a model ? -.-
May 03, 2010 10:00 PM|LINK
You can download MVC Futures from the URL you found (http://aspnet.codeplex.com/releases/view/41742), which contains a file Microsoft.Web.Mvc.dll. Drop this file into your application (it won't overwrite System.Web.Mvc.dll), and use the ModelCopier class. See http://weblogs.asp.net/shijuvarghese/archive/2010/04/27/asp-net-mvc-modelcopier.aspx for an example of how to use this type.
The ModelCopier from MVC Futures is a meant for very simple scenarios, such as the one you have. If you need something more complex, you may want to try the excellent AutoMapper library.
imran_ku07
All-Star
45815 Points
7698 Posts
MVP
Re: Fast way to copy a model ? -.-
May 04, 2010 03:11 AM|LINK
I think you should also need to aware about, Shallow Copy, Deep Copy in .NET
Excellent Windows VPS Hosting
Imran Baloch MVP, MVB, MCP, MCTS, MCPD
imran_ku07
All-Star
45815 Points
7698 Posts
MVP
Re: Fast way to copy a model ? -.-
May 04, 2010 05:26 AM|LINK
Here is the simplist Shallow Copying Example,
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { A a1 = new A { S1 = "1", S2 = "2", S3 = "3" }; A a2 = (A)a1.Clone(); a1.S1 = "4";a1.S2 = "5";a1.S3 = "6"; Console.WriteLine(a1.S1); Console.WriteLine(a1.S2); Console.WriteLine(a1.S3); Console.WriteLine(a2.S1); Console.WriteLine(a2.S2); Console.WriteLine(a2.S3); Console.ReadLine(); } } public class A { public string S1 { get; set; } public string S2 { get; set; } public string S3 { get; set; } public object Clone() { return this.MemberwiseClone(); } } }Excellent Windows VPS Hosting
Imran Baloch MVP, MVB, MCP, MCTS, MCPD