LinqDataSource and Image field in SQL Server.

Last post 05-12-2008 1:39 PM by chenriks. 2 replies.

Sort Posts:

  • LinqDataSource and Image field in SQL Server.

    03-12-2008, 9:10 PM
    • Loading...
    • Cherven
    • Joined on 07-18-2006, 9:19 AM
    • Canada
    • Posts 6

    I started this thread on http://www.telerik.com/community/forums/thread/b311D-bbegdh.aspx

    Here is the main part:

     

    I found some nuances in work of  bundle LINQ and RadGrid (RadGrid it is GridView from Telerik). The table in MSSQL that I use in RadGrid has Image field. I do not use this field in RadGrid . When I set "Delay Loaded = true" for this field in LINQ designer then after updating other fields via grid the RadGrid or LINQ (I don't know which) erases this Image field. If I set "Delay Loaded = false" then no problem - I can update rows in grid and Image field untouched.

    Here is LinqDataSource.

    <asp:LinqDataSource ID="ProcesesLinqDataSource" runat="server" ContextTypeName = "HomeDepotWebApp.Classes.HDPortalDataContext" TableName = "Processes" EnableUpdate = "True" Where = "WBS.Contains(@WBSPart) &amp;&amp; VendorName == @VendorName &amp;&amp; CustomerStoreId == @CustomerStoreId &amp;&amp; PONumber == @PONumber &amp;&amp; SAPArticleNumber == @SAPArticleNumber" OnSelecting = "ProcesesLinqDataSource_Selecting">
    <WhereParameters>
    <asp:QueryStringParameter QueryStringField="WBSPart" Name="WBSPart" Type="String" />
    <asp:ControlParameter ControlID="Vendor" Name="VendorName" PropertyName="Text" Type="String" />
    <asp:ControlParameter ControlID="Store" Name="CustomerStoreId" PropertyName="Text" Type="String" />
    <asp:ControlParameter ControlID="PONumber" Name="PONumber" PropertyName="Text" Type="String" />
    <asp:ControlParameter ControlID="SAPArticleNumber" Name="SAPArticleNumber" PropertyName="Text" Type="String" />
    </WhereParameters>
    </asp:LinqDataSource>


    Here is log from SQL Server Profiler (Delay Loaded = True)

     
    exec sp_executesql N'UPDATE [dbo].[Process]
    SET [PackingSlip] = @p2, [QtyShipped] = @p3
    WHERE ([ProcessId] = @p0) AND ([timestamp] = @p1)
    SELECT [t1].[timestamp]
    FROM [dbo].[Process] AS [t1]
    WHERE  ((@@
    ROWCOUNT) > 0) AND ([t1].[ProcessId] = @p4)',N'@p0 int,@p1 timestamp,@p2 image,@p3 int,@p4 int'
    ,@p0=3,@p1=0x000000000009EC49,@p2=NULL,@p3=2,@p4=3
     


    PackingSlip it is my Image filed.


    Here is log from SQL Server Profiler (Delay Loaded = False)

     
    exec sp_executesql N'UPDATE [dbo].[Process]
    SET [QtyShipped] = @p2
    WHERE ([ProcessId] = @p0) AND ([timestamp] = @p1)
    SELECT [t1].[timestamp]
    FROM [dbo].[Process] AS [t1]
    WHERE ((@@
    ROWCOUNT) > 0) AND ([t1].[ProcessId] = @p3)',N'@p0 int,@p1 timestamp,@p2 int,@p3 int'
    ,@p0=3,@p1=0x000000000009EC4A,@p2=22,@p3=3


    So there is problem? In LINQ, in RadGrid or in Me?

    The ansver from Telerik: I have checked your example and I have to say that you will get exactly the same result with MS GridView.

    Is it bug of LinqDataSource?

    Thanks,

    Bohdan

    never stop learning
  • Re: LinqDataSource and Image field in SQL Server.

    03-12-2008, 9:42 PM
    Answer

    It doesn't look like you are using the new Dynamic Data feature, so you may want to repost your question in the correct forum. Please see the intro post for what ASP.NET Dynamic Data is about.

    Thanks,

    MaĆ­ra

    This posting is provided "AS IS" with no warranties, and confers no rights.
  • Re: LinqDataSource and Image field in SQL Server.

    05-12-2008, 1:39 PM
    • Loading...
    • chenriks
    • Joined on 09-27-2006, 1:07 PM
    • Redmond, WA
    • Posts 48
    • AspNetTeam

    During CUD operations, LinqDataSource will call the property setters for any columns which are included in the values dictionaries sent from the databound control.  It sounds as if the databound control is including the Image field in the dictionary with an empty value.    It's probably a case where the column is being included, but since the image can't be displayed in the grid the data is empty.  You should be able to handle an event for Updating on the databound control side to see what data it's sending to the LinqDataSource.

    Christy Henriksson
    ASP.NET Team
Page 1 of 1 (3 items)