I need to insert large amount of data into SqlServer 2008. My project is based on linq-to-sql.
I process csv file with 100.000 rows. Each row is mapped to Order object. Order contains also collection of Category and Code objects. I need to map each row to object in order to validate it.
Then I need to insert all these objects into database.
List<Order> orders = Import("test.csv"); db.Orders.InsertAllOnSubmit(orders); db.SubmitChanges(); OR foreach(Order order in orders) db.Orders.InsertOnSubmit(order); db.SubmitChanges();
Both ways are slow. Is there any workaround? I may use other approach than l2sql for this task.
I read about SqlBulkCopy class - would it handle inserting child entities as well?
I have a database table with all columns to allow nulls for testing purposes. Between all of my columns I have int, varchar or bit datatypes. When I try to submit the form I get the following error message:
Value was either too large or too small for an Int32.
Here is the code:
using (storeDataContext db = new storeDataContext()) {
I am struggling to create a webservice method using LINQ technology and to populate a dropdown in a form. Here is the Webservice code.
[WebMethod]
public string[] GetAllCountries() { LinqClassesDataContext db = new LinqClassesDataContext(); var q = from c in db.ListContinents()select c; return q.ToList() ; }
And here is the form code behind
protectedvoid Page_Load(object sender, EventArgs e) { WSClass WS = new WSClass();//bool ds = WS.GetAllCountries(); var v = WS.GetAllCountries(); ddlContinent.DataSource = v; ddlContinent.DataBind(); }
I am building a website where i need a page where user can upload large video files, i have created WCF service with streaming but i am calling that WCF service from Button_Click event of web page.
I have used below mentioned article for WCF service creation
WCF Streaming
I have used streaming as it should be efficient and should not be buffered in memory of server.
Now questions
1) I am having doubts that the entire file is uploaded to the web server and then it is transferred to WCF Service server...if this is true then i am not getting advantage of streaming as well as iis and web server will be down very soon if user uploads large file or multiple user are uploading files con currently
2) Is there any other efficient way to do same operation with some other technique
EDIT :
If I am not calling WCF Service method from ASP .Net code in that case also it is transferring bytes to the web server which i have checked with HTTPFox
I have checked above thing with upload control and putting one button on UI whose click event is bound to one method in code behind.
So, still i am having that confusion that how data is transferred
Client Machine - Web Server (ASP .Net Application) - Service Server (WCF Service) Client Machine - Service Server (WCF Service)
NOTE : If i am putting a debug point on button_click and uploading 10 kb file it hits that in less then 1 sec. but if i am uploading 50 mb file then it is taking time.
I placed code of calling WCF service inside that button_click event
I need to create a method which looks through a large string of text, and determines which words (apart from words like "a" "and" "the") are the most frequently used. I would like to determine which are the top 3 most frequently used words in a string of text...is this possible?
The number of fields may grow with attributes for more specific product tyes. The description may contain a large amount of data. I want to create a slim version of this product class that only contains the data needed. I'm only displaying 4 of the 12 fields when listing products on a category page. It seems like a waste to retrieve all of the data when most of it isn't being used. I created a parent class of ProductListing that contains the 4 fields I need for the category page
ProductId ShortTitle Price Img
Then created a class of Product that inherits from ProductListing containing all product data. It seems backwards as "ProductListing" is not a kind of "Product" but I just started reading about inheritance a few months ago so it's stil a little new to me. Is there a better way to get a slim object so I'm not pulling data I don't need? Is the solution I have in place fine how it is?
I fetched Blog Description and displayed on the ListView control when user search for the blog titlewise. But it is everything displaying on blog description. I want to display first 4/5 lines only and then it should display ..... [ continue ]
How to resize large number of images in a folder  in c# windows application. I am using following code to resize images of my folders. If images are less than 1600 ( in number) then no problem but if images are more than 1600 then i am getting error. My code is given below:-
public static Image ResizeImage(string file, int width, int height, bool onlyResizeIfWider) { using (Image image = Image.FromFile(file)) { // Prevent using images internal thumbnail image.RotateFlip(RotateFlipType.Rotate180FlipNone); image.RotateFlip(RotateFlipType.Rotate180FlipNone);
[Code] ....
Thumbnail creation in ASP.Net: System.Runtime.InteropServices.ExternalException: A generic error occurred in GDI
I'm developing chat application on asp.net mvc, in my app, user can create room and invite other join to chat, but don't need to save chat room information.So, I designed to save all chat message ,room information and user info in Session and clear it when owner close the room.I'm worry about stressing server when I save alot of data (include room info, user info, and message) in Session if there are up to 5000 rooms created and alot of messages transfered in that room.Is my solution good enough ? is it ok to save in Session ?
I have to implement broker and dealer socket connection like in share market i.e. it should connect at 9 AM and stop at 3.30 PM and repeat in next morning ...
so following is my requirement
1) i have to create application object once in day at 9 AM and destroyed at particular end day 3.30 PM.
My question is how to destroyed application object at given particular time ... i think this can be done in application_end handler in global.asax ... but my question is when no request is made at that time then what happened..
I'm trying to deploy an ASP.NET application using InnoSetup. I need to perform the following tasks:
Create an IIS application.
Create a new IIS application pool and set it's .NET version to 4.
Set the application pool of the new application to the new application pool.
I have found a script to create a virtual directory, but I need an application and application pool:
procedure CreateIISVirtualDir(); var IIS, WebSite, WebServer, WebRoot, VDir: Variant; ErrorCode: Integer; begin { Create the main IIS COM Automation object }[code]......
I want to create a LINQ SQL-Group-Query... This is my LINQ-Query:
[Code]....
I want to Group this, like this normal SQL-Query do it?
[Code]....
Furtermore, when iam using this normal sql query the programm needs a Type .. for example Dim reqdata(of Iqueryable(of xxx)("sql query...") ... whats the Type of this ? When i select more tables than ones ? there is said thats <anonymous type> ?
In my experience building web applications, I've always used a n-tier approach. A DAL that gets data from the db and populates the objects, and BLL that gets objects from the DAL and performs any business logic required on them, and the website that gets it's display data from the BLL.I've recently started learning LINQ, and most of the examples show the queries occurring right from the Web Application code-behinds(it's possible that I've only seen overly simplified examples). In the n-tier architectures, this was always seen as a big no-no.I'm a bit unsure of how to architect a new Web Application.
I'm trying to use linq to sql for my project (very short deadline), and I'm kind of in a bind. I don't know the best way to have a data context handy per request thread. I want something like a singleton class from which all my repository classes can access the current data context. However, singleton class is static and is not thread-safe and therefore not suitable for web apps. I want something that would create a data context at the beginning of the request and dispose of it along with the request
I am developing sample web application which use C#, and LINQ to SQL. The application is very very slow and it takes about 2 secs to navigate between pages. I have already used SQL Profiler and monitor the calls to the SQL server. All SQLs looks normal to me and their execution time is always about 1 or 2 millisecs.I tried the same application in another PC and it is the same. So, it is not because of my computer performance.
i want create a class Library work with SQL Linq ,when i create a LINQ Data Class it automatic create some connectionString and use the database namemy question is can i change some settings that, use this class Library in difrent website with difrent connectionStrings?
i"ve build a small (verry small) test app with a UI and a domain model and i'm able to show all the data from one table but now i wanna create a query so i only get the data i want but i have no idea how to do this. i've created a domain model with a entity class, an abstract and a concrete repository (see code)
[Code]....
namespace winkelketen.domain.Abstract{ public interface IwinkelketenRepository { IQueryable<Winkelketen> Winkelketen { get; } }} namespace winkelketen.domain.Concrete{ public class SqlWinkelketenRepository : IwinkelketenRepository { private Table<Winkelketen> productsTable; public SqlWinkelketenRepository(string connectionString) { productsTable = (new DataContext(connectionString)).GetTable<Winkelketen>(); } public IQueryable<Winkelketen> Winkelketen { get { return productsTable; } } }}
and then i created a UI with a controller
[Code]....
and a view
[Code]....
could something give me some tips how to do this or how to get started?
I want to create an install script for a simple little CMS I have created for myself... I want to pass the connection string and then create my tables.
I found the following example on MSDN:
[URL]
My question is how do I pass the username and password to the DB...
i want define connectionSreing in the web.config and then use it for DataContext ConnectionString. i do that : 1. i creat a class in App_Code :(MisaghDB is my database)
partial class MisaghDataContext { partial void OnCreated() { this.Connection.ConnectionString = ConfigurationManager.ConnectionStrings["MisaghDBConnectionString"].ConnectionString; } // or public partial class MisaghDataContext { public MisaghDataContext() : base (ConfigurationManager.ConnectionStrings["MisaghDBConnectionString"].ConnectionString) { OnCreated(); } } }
2. Add the connection string to my web.config file:
3. Right click on the DBML file design surface and chose properties. Select "none" for the Connection property.now should i change DBML file designer.cs (Misagh.designer.cs) ? The code should I delete in this file(DBMLfile designer.cs)? this is a part of my DBMLfile designer.cs :
[global::System.Data.Linq.Mapping.DatabaseAttribute(Name="MisaghDB")] public partial class MisaghDataContext : System.Data.Linq.DataContext { private static System.Data.Linq.Mapping.MappingSource mappingSource = new AttributeMappingSource(); public NorthwindDataContext() : base(global::WindowsFormsApplication2.Properties.Settings.Default.NorthwindConnectionString, mappingSource) { OnCreated(); } public NorthwindDataContext(string connection) : base(connection, mappingSource) { OnCreated(); } public NorthwindDataContext(System.Data.IDbConnection connection) : base(connection, mappingSource) { OnCreated(); } public NorthwindDataContext(string connection, System.Data.Linq.Mapping.MappingSource mappingSource) : base(connection, mappingSource) { OnCreated(); } public NorthwindDataContext(System.Data.IDbConnection connection, System.Data.Linq.Mapping.MappingSource mappingSource) : base(connection, mappingSource) { OnCreated(); } ............}
I am trying to handle concurrency in my application. Basically if user A has a support ticket open which currently has a status of 'Active' and user 'B' opens the same ticket and closes it (changing its status to closed), I would expect a confict execepton to be thown when user 'A' tries to close the support ticket. For some reason this is not happening. I have checked that Update check is set to 'Always' in the dbml file. Here is an exerpt of my code. // Update 'Active' lead to 'Close'