Send data from code behind
-
How to send data to database through linq from code behind tahnks
-
How to send data to database through linq from code behind tahnks
What does it mean? Is the question clear to you?
Niladri Biswas
-
How to send data to database through linq from code behind tahnks
There is no special method for doing this. However, you might want to consider your architecture. I don't think puting LINQ queries into the code behind isgood OOP. I have allways placed the LINQ stuff in the DataContext helper classes. This allwos you to reuse the code more efficently. However, if you are not doing LINQ to SQL, you may find some instances where you might want to directly use LINQ to XML in the code behind, although I can't think of any.
-
There is no special method for doing this. However, you might want to consider your architecture. I don't think puting LINQ queries into the code behind isgood OOP. I have allways placed the LINQ stuff in the DataContext helper classes. This allwos you to reuse the code more efficently. However, if you are not doing LINQ to SQL, you may find some instances where you might want to directly use LINQ to XML in the code behind, although I can't think of any.
Thanks Actually I was trying to insert data using Listview where Linq is used as a data source. But there is a datetime field to be inserted thats need to convert from string to datetime. for this i need to send data from code behind as we usually do when use objectdatasource like.. e.InputParameters["Parameter"] = value;
-
Thanks Actually I was trying to insert data using Listview where Linq is used as a data source. But there is a datetime field to be inserted thats need to convert from string to datetime. for this i need to send data from code behind as we usually do when use objectdatasource like.. e.InputParameters["Parameter"] = value;
Okay I understand now. The way I have extended functionality of the ORM is to create a partial class extension. This will save you headaches in the future. If you place all your code in the auto generated classes from SQLMetal or the Visual Studio ORM, the generator will write over your changes. There are a couple of methods for accomplishing what you would like to do. If the SQL db artifact is a string then you will need to convert the string to a DateTime Object, or use a RegEx to parse the string into the desired output. Is the SQL db artiface is a DateTime SQL column, then the ORM will create an association to the LINQ model as a DateTime Field/Property. No conversion necessary, However you may need to format the DateTime object to match your achitecural specifications. Additionally, there is an event model which is created if you used SQLMetal or the Studio ORM mapper to generate your stub. You can also overload these events in your partial class. CURD drives most of the events, with the exception of a few that are driven pre and post CRUD operations. Ie. LINQ2SQL driven. You could even use a combination of DateTime and String objects to map to your ORM in the partial classes, provied you follow the DataContext constructs and event handeling for custom attributes. Some resources: DateTime Conversion and Formating Thread[^]
-
Okay I understand now. The way I have extended functionality of the ORM is to create a partial class extension. This will save you headaches in the future. If you place all your code in the auto generated classes from SQLMetal or the Visual Studio ORM, the generator will write over your changes. There are a couple of methods for accomplishing what you would like to do. If the SQL db artifact is a string then you will need to convert the string to a DateTime Object, or use a RegEx to parse the string into the desired output. Is the SQL db artiface is a DateTime SQL column, then the ORM will create an association to the LINQ model as a DateTime Field/Property. No conversion necessary, However you may need to format the DateTime object to match your achitecural specifications. Additionally, there is an event model which is created if you used SQLMetal or the Studio ORM mapper to generate your stub. You can also overload these events in your partial class. CURD drives most of the events, with the exception of a few that are driven pre and post CRUD operations. Ie. LINQ2SQL driven. You could even use a combination of DateTime and String objects to map to your ORM in the partial classes, provied you follow the DataContext constructs and event handeling for custom attributes. Some resources: DateTime Conversion and Formating Thread[^]
Thanks a lot