सभी पंक्तियों को एक तालिका से दूसरी तालिका में कॉपी करने का सबसे अच्छा तरीका क्या है?
मैं किसी तालिका में सभी पंक्तियां प्राप्त करने कोड के नीचे की कोशिश की:Azure तालिका संग्रहण में सभी पंक्तियों को कॉपी करें
TableServiceContext _dataContext;
public IEnumerable<T> GetAllEntities()
{
IQueryable<T> query = null;
try
{
query = _dataContext.CreateQuery<T>(_tableName);
}
catch (Exception ex)
{
}
return query.ToArray();
}
लेकिन यह पंक्तियों से अधिक के आसपास 900 मैं पंक्तियों के हजारों की कुछ सैकड़ों प्राप्त नहीं करता है।
अपडेट किया गया कोड:
public class TableRepository<T> : IRepository<T>
where T : TableEntity
{
protected readonly string _tableName;
protected readonly TableServiceContext _dataContext;
protected readonly CloudTable _tableReference;
public TableRepository(string tableName, CloudTableClient tableClient)
{
_tableName = tableName;
_dataContext = tableClient.GetTableServiceContext();
_tableReference = tableClient.GetTableReference(tableName);
_dataContext.ResolveType = ResolveEntityType;
_dataContext.MergeOption = System.Data.Services.Client.MergeOption.NoTracking;
}
public IEnumerable<T> GetAllEntities()
{
List<T> allEntities = new List<T>();
try
{
Microsoft.WindowsAzure.Storage.Table.TableContinuationToken tableContinuationToken = null;
do
{
var queryResponse = _tableReference.ExecuteQuerySegmented<T>(null, tableContinuationToken, null, null);
tableContinuationToken = queryResponse.ContinuationToken;
allEntities.AddRange(queryResponse.Results);
}
while (tableContinuationToken != null);
}
catch (Exception ex)
{
throw new DALException(_tableName,_dataContext.BaseUri.OriginalString, "An error occured while querying data", ex);
}
return allEntities;
}
}
लेकिन त्रुटि के साथ:
Error 121 'T' must be a non-abstract type with a public parameterless constructor in order to use it as parameter 'TElement' in the generic type or method 'Microsoft.WindowsAzure.Storage.Table.CloudTable.ExecuteQuerySegmented
मुझे यह त्रुटि मिल रही है- त्रुटि 'टी' सामान्य पैरामीटर या विधि – Seenu
में पैरामीटर 'टेलीमेंट' के रूप में इसका उपयोग करने के लिए सार्वजनिक पैरामीटर रहित कन्स्ट्रक्टर के साथ एक गैर-सार प्रकार होना चाहिए। क्या आप कोड साझा कर सकते हैं ? –
नवीनतम कोड – Seenu